public function TranslatableInterface::addTranslation in Drupal 9
Same name and namespace in other branches
- 8 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.
1 method overrides TranslatableInterface::addTranslation()
- ContentEntityBase::addTranslation in core/
lib/ Drupal/ Core/ Entity/ ContentEntityBase.php - Adds a new translation to the translatable object.
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 = []);