function TranslatableInterface::addTranslation
Same name in other branches
- 9 core/lib/Drupal/Core/TypedData/TranslatableInterface.php \Drupal\Core\TypedData\TranslatableInterface::addTranslation()
- 10 core/lib/Drupal/Core/TypedData/TranslatableInterface.php \Drupal\Core\TypedData\TranslatableInterface::addTranslation()
- 11.x core/lib/Drupal/Core/TypedData/TranslatableInterface.php \Drupal\Core\TypedData\TranslatableInterface::addTranslation()
Adds a new translation to the translatable object.
To create a translation of an entity prefilled with the original data:
$entity->addTranslation($langcode, $entity->toArray());
Parameters
string $langcode: The language code identifying the translation.
array $values: (optional) An array of initial values to be assigned to the translatable fields. Defaults to none.
Return value
$this
Throws
\InvalidArgumentException If an invalid or existing translation language is specified.
File
-
core/
lib/ Drupal/ Core/ TypedData/ TranslatableInterface.php, line 118
Class
- TranslatableInterface
- Interface for translatable data.
Namespace
Drupal\Core\TypedDataCode
public function addTranslation($langcode, array $values = []);
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.