Skip to content

Instantly share code, notes, and snippets.

@johnny-aroza
Created May 3, 2024 10:06
Show Gist options
  • Select an option

  • Save johnny-aroza/9da181a25d27971ef34b5bf775cd8b1e to your computer and use it in GitHub Desktop.

Select an option

Save johnny-aroza/9da181a25d27971ef34b5bf775cd8b1e to your computer and use it in GitHub Desktop.
Drupal add Translation through code
$language = \Drupal::languageManager()->getLanguage('es-ar');
$translatedNode = $entity->addTranslation($language->getId());
$translatedNode->setTitle('ec-er Title');
$translatedNode->save();
dump($translatedNode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment