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 54 of file DefaultLocalization.php.
Public Member Functions | |
__construct (PersistenceFacade $persistenceFacade, Configuration $configuration, $defaultLanguage, $translationType, $languageType) | |
getDefaultLanguage () | |
getSupportedLanguages () | |
loadTranslatedObject (ObjectId $oid, $lang, $useDefaults=true) | |
loadTranslation (PersistentObject $object, $lang, $useDefaults=true, $recursive=true) | |
saveTranslation (PersistentObject $object, $lang, $recursive=true) | |
deleteTranslation (ObjectId $oid, $lang=null) | |
deleteLanguage ($lang) | |
Protected Member Functions | |
loadTranslationImpl (PersistentObject $object, $lang, $useDefaults=true) | |
saveTranslationImpl (PersistentObject $object, $lang) | |
Constructor & Destructor Documentation
__construct | ( | PersistenceFacade | $persistenceFacade, |
Configuration | $configuration, | ||
$defaultLanguage, | |||
$translationType, | |||
$languageType | |||
) |
Configuration.
- Parameters
-
$persistenceFacade $configuration $defaultLanguage $translationType Entity type name $languageType Entity type name
Definition at line 72 of file DefaultLocalization.php.
Member Function Documentation
getDefaultLanguage | ( | ) |
Implements Localization.
Definition at line 97 of file DefaultLocalization.php.
getSupportedLanguages | ( | ) |
- See also
- Localization::getSupportedLanguages() Reads the configuration section 'languages'
Implements Localization.
Definition at line 105 of file DefaultLocalization.php.
loadTranslatedObject | ( | ObjectId | $oid, |
$lang, | |||
$useDefaults = true |
|||
) |
Implements Localization.
Definition at line 126 of file DefaultLocalization.php.
loadTranslation | ( | PersistentObject | $object, |
$lang, | |||
$useDefaults = true , |
|||
$recursive = true |
|||
) |
- See also
- Localization::loadTranslation()
Implements Localization.
Definition at line 135 of file DefaultLocalization.php.
|
protected |
Load a translation of a single entity for a specific language.
- Parameters
-
$object A reference to the object 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
- A reference to the translated object.
- Exceptions
-
IllegalArgumentException
Definition at line 172 of file DefaultLocalization.php.
saveTranslation | ( | PersistentObject | $object, |
$lang, | |||
$recursive = true |
|||
) |
- See also
- Localization::loadTranslation()
- Note
- Only values with tag TRANSLATABLE are stored.
Implements Localization.
Definition at line 207 of file DefaultLocalization.php.
|
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 230 of file DefaultLocalization.php.
deleteTranslation | ( | ObjectId | $oid, |
$lang = null |
|||
) |
Implements Localization.
Definition at line 262 of file DefaultLocalization.php.
deleteLanguage | ( | $lang | ) |
- See also
- Localization::deleteLanguage()
Implements Localization.
Definition at line 288 of file DefaultLocalization.php.