TranslatableInterface
interface TranslatableInterface (View source)
Interface for translatable data.
Classes implementing this interface do not necessarily support translations.
To detect whether an entity type supports translation, call EntityTypeInterface::isTranslatable().
Many entity interfaces are composed of numerous other interfaces such as this one, which allow implementations to pick and choose which features to support through stub implementations of various interface methods. This means that even if an entity class implements TranslatableInterface, it might only have a stub implementation and not a functional one.
Methods
Returns the translation language.
Checks whether the translation is the default one.
Checks whether the translation is new.
Returns the languages the data is translated to.
Gets a translation of the data.
Returns the translatable object referring to the original language.
Checks there is a translation for the given language code.
Adds a new translation to the translatable object.
Removes the translation identified by the given language code.
Returns the translation support status.
Details
LanguageInterface
language()
Returns the translation language.
bool
isDefaultTranslation()
Checks whether the translation is the default one.
bool
isNewTranslation()
Checks whether the translation is new.
LanguageInterface[]
getTranslationLanguages(bool $include_default = TRUE)
Returns the languages the data is translated to.
$this
getTranslation($langcode)
Gets a translation of the data.
The returned translation has to be of the same type than this typed data object.
$this
getUntranslated()
Returns the translatable object referring to the original language.
bool
hasTranslation(string $langcode)
Checks there is a translation for the given language code.
$this
addTranslation(string $langcode, array $values = [])
Adds a new translation to the translatable object.
To create a translation of an entity prefilled with the original data:
removeTranslation(string $langcode)
Removes the translation identified by the given language code.
bool
isTranslatable()
Returns the translation support status.