Trait TranslateTrait
Contains translation methods aimed to help managing multiple translations for an entity.
Method Summary
-
getOrCreateTranslation() public
Returns the entity containing the translated fields for this object and for the specified language. If the translation for the passed language does not exist, a new empty entity will be created.
This method marks
_translationsas dirty to facilitate saving. -
hasTranslation() public
Checks whether a translation exists for the given language.
-
translation() public
Returns the entity containing the translated fields for this object and for the specified language, or null if the translation does not exist.
Method Detail
getOrCreateTranslation() ¶ public
getOrCreateTranslation(string $language): Cake\Datasource\EntityInterface
Returns the entity containing the translated fields for this object and for the specified language. If the translation for the passed language does not exist, a new empty entity will be created.
This method marks _translations as dirty to facilitate saving.
Parameters
-
string$language Language to return entity for.
Returns
Cake\Datasource\EntityInterfacehasTranslation() ¶ public
hasTranslation(string $language): bool
Checks whether a translation exists for the given language.
Parameters
-
string$language Language to check.
Returns
booltranslation() ¶ public
translation(string $language): Cake\Datasource\EntityInterface|null
Returns the entity containing the translated fields for this object and for the specified language, or null if the translation does not exist.
Parameters
-
string$language Language to return entity for.
Returns
Cake\Datasource\EntityInterface|null