3 namespace Drupal\Core\TypedData;
6 * Interface for translatable data.
8 interface TranslatableInterface {
11 * Returns the translation language.
13 * @return \Drupal\Core\Language\LanguageInterface
14 * The language object.
16 public function language();
19 * Checks whether the translation is the default one.
22 * TRUE if the translation is the default one, FALSE otherwise.
24 public function isDefaultTranslation();
27 * Checks whether the translation is new.
30 * TRUE if the translation is new, FALSE otherwise.
32 public function isNewTranslation();
35 * Returns the languages the data is translated to.
37 * @param bool $include_default
38 * (optional) Whether the default language should be included. Defaults to
41 * @return \Drupal\Core\Language\LanguageInterface[]
42 * An associative array of language objects, keyed by language codes.
44 public function getTranslationLanguages($include_default = TRUE);
47 * Gets a translation of the data.
49 * The returned translation has to be of the same type than this typed data
53 * The language code of the translation to get or
54 * LanguageInterface::LANGCODE_DEFAULT
55 * to get the data in default language.
58 * A typed data object for the translated data.
60 * @throws \InvalidArgumentException
61 * If an invalid or non-existing translation language is specified.
63 public function getTranslation($langcode);
66 * Returns the translatable object referring to the original language.
69 * The translation object referring to the original language.
71 public function getUntranslated();
74 * Returns TRUE there is a translation for the given language code.
76 * @param string $langcode
77 * The language code identifying the translation.
80 * TRUE if the translation exists, FALSE otherwise.
82 public function hasTranslation($langcode);
85 * Adds a new translation to the translatable object.
87 * @param string $langcode
88 * The language code identifying the translation.
89 * @param array $values
90 * (optional) An array of initial values to be assigned to the translatable
91 * fields. Defaults to none.
95 * @throws \InvalidArgumentException
96 * If an invalid or existing translation language is specified.
98 public function addTranslation($langcode, array $values = []);
101 * Removes the translation identified by the given language code.
103 * @param string $langcode
104 * The language code identifying the translation to be removed.
106 public function removeTranslation($langcode);
109 * Returns the translation support status.
112 * TRUE if the object has translation support enabled.
114 public function isTranslatable();