Detailed Description
DefaultLocalization is a Localization implementation that saves translations in the store.
Entity instances are localized value by value, where a translation of a value of one instance into a specific language is represented by one instance of the translation entity type (e.g. Translation).
The translation entity type must have the attributes 'objectid', 'attribute', 'translation', 'language' with the appropriate getter and setter methods. It is defined calling the Localization::setTranslationType() method.
A translation is only stored for values with the tag TRANSLATABLE (see AttributeDescription). This allows to exclude certain values e.g. date values from the translation process by omitting this tag.
The default language is defined in the configuration key 'defaultLanguage' in section 'localization'.
All languages available for translation are either defined in the configuration section 'languages', where each language has it's own entry: e.g. en = English or in a language entity type (e.g. Language). The language entity type must have the attributes 'code' and 'name' with the appropriate getter and setter methods. It is defined calling the Localization::setLanguageType() method. If translation entity type and configuration section are defined, the configuration section is preferred.
Definition at line 58 of file DefaultLocalization.php.
Public Member Functions | |
__construct (PersistenceFacade $persistenceFacade, Configuration $configuration, EventManager $eventManager, $defaultLanguage, $translationType, $languageType) | |
__destruct () | |
getDefaultLanguage () | |
getSupportedLanguages () | |
loadTranslatedObject (ObjectId $oid, $lang, $useDefaults=true) | |
loadTranslation (PersistentObject $object, $lang, $useDefaults=true, $recursive=true, $marker=null) | |
saveTranslation (PersistentObject $object, $lang, $recursive=true) | |
deleteTranslation (ObjectId $oid, $lang=null) | |
deleteLanguage ($lang) | |
afterCreate (PersistenceEvent $event) | |
Public Member Functions inherited from Localization | |
loadTranslation (PersistentObject $object, $lang, $useDefaults=true, $recursive=true) | |
Protected Member Functions | |
loadTranslationImpl (PersistentObject $object, $lang, $useDefaults=true) | |
saveTranslationImpl (PersistentObject $object, $lang) | |
Constructor & Destructor Documentation
◆ __construct()
__construct | ( | PersistenceFacade | $persistenceFacade, |
Configuration | $configuration, | ||
EventManager | $eventManager, | ||
$defaultLanguage, | |||
$translationType, | |||
$languageType | |||
) |
Configuration.
- Parameters
-
$persistenceFacade $configuration $eventManager $defaultLanguage $translationType Entity type name $languageType Entity type name
Definition at line 84 of file DefaultLocalization.php.
◆ __destruct()
__destruct | ( | ) |
Destructor.
Definition at line 117 of file DefaultLocalization.php.
Member Function Documentation
◆ getDefaultLanguage()
getDefaultLanguage | ( | ) |
Implements Localization.
Definition at line 124 of file DefaultLocalization.php.
◆ getSupportedLanguages()
getSupportedLanguages | ( | ) |
- See also
- Localization::getSupportedLanguages() Reads the configuration section 'languages'
Implements Localization.
Definition at line 132 of file DefaultLocalization.php.
◆ loadTranslatedObject()
loadTranslatedObject | ( | ObjectId | $oid, |
$lang, | |||
$useDefaults = true |
|||
) |
Implements Localization.
Definition at line 153 of file DefaultLocalization.php.
◆ loadTranslation()
loadTranslation | ( | PersistentObject | $object, |
$lang, | |||
$useDefaults = true , |
|||
$recursive = true , |
|||
$marker = null |
|||
) |
- See also
- Localization::loadTranslation()
Definition at line 162 of file DefaultLocalization.php.
◆ loadTranslationImpl()
|
protected |
Load a translation of a single entity for a specific language.
- Parameters
-
$object PersistentObject instance to load the translation into. The object is supposed to have it's values in the default language. $lang The language of the translation to load. $useDefaults Boolean whether to use the default language values for untranslated/empty values or not. Optional, default is true.
- Returns
- PersistentObject instance
- Exceptions
-
IllegalArgumentException
Definition at line 220 of file DefaultLocalization.php.
◆ saveTranslation()
saveTranslation | ( | PersistentObject | $object, |
$lang, | |||
$recursive = true |
|||
) |
- See also
- Localization::loadTranslation()
- Note
- Only values with tag TRANSLATABLE are stored.
Implements Localization.
Definition at line 268 of file DefaultLocalization.php.
◆ saveTranslationImpl()
|
protected |
Save a translation of a single entity for a specific language.
Only the values that have a non-empty value are considered as translations and stored.
- Parameters
-
$object An instance of the entity type that holds the translations as values. $lang The language of the translation.
Definition at line 291 of file DefaultLocalization.php.
◆ deleteTranslation()
deleteTranslation | ( | ObjectId | $oid, |
$lang = null |
|||
) |
Implements Localization.
Definition at line 330 of file DefaultLocalization.php.
◆ deleteLanguage()
deleteLanguage | ( | $lang | ) |
- See also
- Localization::deleteLanguage()
Implements Localization.
Definition at line 356 of file DefaultLocalization.php.
◆ afterCreate()
afterCreate | ( | PersistenceEvent | $event | ) |