0

How can I translate a taxonomy term programmatically in drupal 8? I found how to get the translated taxonomy term programmatically? but this is only related to d7.

5

In D8 you can translate entities with addTranslation().

This is an example for a taxonomy term:

$term->addTranslation($langcode, [
  'name' => 'translated term',
])->save();

You can provide values for all translatable fields in the array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.