Question
How to translate a node programmatically and how to get a field translated in Drupal 8
Exemples:
$translation = $entity->getTranslation('de');
$translation = \Drupal::entityManager()->getTranslationFromContext($entity);
$node_es = $node->addTranslation('es');
$node_es->title = 'Mi prueba!';
$node_es->body->value = '<p>El cuerpo de mi nodo.</p>';
$node_es->body->format = 'full_html';
$node_es->save();
Add new comment