I'm using a hook_node_presave and I want to detect which field is updated when the translated node is updated. Here is my code :
function hook_import_node_presave(\Drupal\node\NodeInterface $node) {
if (!$node->isNew()){
$entityFieldManager = \Drupal::service('entity_field.manager');
$fields = $entityFieldManager->getFieldDefinitions('node', 'article');
foreach($fields as $field_name => $field_definition) {
foreach ($node->getTranslationLanguages() as $langcode => $langcode_value) {
$node = $node->getTranslation($langcode);
if ($node->get($field_name)->getValue() != $node->original->get($field_name)->getValue()) {
// do something
}
}
}
}
}
However,
$node = $node->getTranslation($langcode);
$node->original->get($field_name)->getValue()
even after "getTranslation()", "original" is still pointing to the default language. I want to get the "original" language of the translated node.