wCMF
3.6
|
Public Member Functions | |
& | getInstance () |
getDefaultLanguage () | |
getSupportedLanguages () | |
getTranslationType () | |
getIncludedInputTypes () | |
& | createTranslationInstance () |
& | loadTranslatedObject ($oid, $lang, $useDefaults=true) |
loadTranslation (&$object, $lang, $useDefaults=true, $recursive=true) | |
saveTranslation (&$object, $lang, $saveEmptyValues=false, $recursive=true) | |
deleteTranslation ($oid, $lang=null) | |
deleteLanguage ($lang) | |
setTranslatedValue (&$obj, $valueName, $dataType, &$translations, $useDefaults) | |
saveTranslatedValue (&$obj, $valueName, $dataType, &$existingTranslations, $lang, $saveEmptyValues) | |
Public Attributes | |
$_supportedLanguages = null | |
Localization is used to store localized entity instances and retrieve them back. 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 entity type that is defined in the key 'translationType' in the configuration section 'i18n' (e.g. Translation).
wCMF - wemove Content Management Framework Copyright (C) 2005-2014 wemove digital solutions GmbH
Licensed under the terms of any of the following licenses at your choice:
See the license.txt file distributed with this work for additional information.
The translation entity type must have the attributes 'objectid', 'attribute', 'translation', 'language' (all DATATYPE_ATTRIBUTE) with the appropriate getter and setter methods.
Localization is done against a default language, which is defined in the configuration key 'defaultLanguage' in section 'i18n'. This means that all entity data in the store is supposed to use the default language except those data stored in Translation instances.
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 an entity tyoe that is defined in the key 'languageType' in the configuration section 'i18n' (e.g. Language). The entity type must have the attributes 'code' and 'name' (all DATATYPE_ATTRIBUTE) with the appropriate getter and setter methods. If entity type and configuration section are defined, the configuration section is preferred. Language key names may conform to ISO 639 language codes, but this is not mandatory. One of the keys must be equal to the value of defaultLanguage.
Generally only values whose datatype does not equal DATATYPE_IGNORE are translatable. To exclude values of a special type (like date values) from the translation, they may be omitted in the array that is given in the key 'inputTypes' in the configuration section 'i18n'. This array lists all input_types whose translations are stored.
Definition at line 65 of file class.Localization.php.
& Localization::getInstance | ( | ) |
Returns an instance of the class.
Definition at line 73 of file class.Localization.php.
Referenced by ListboxController\executeKernel(), DeleteController\executeKernel(), TreeViewController\executeKernel(), SaveController\executeKernel(), InsertController\executeKernel(), AsyncPagingController\executeKernel(), DisplayController\executeKernel(), g_getOIDs(), NodeUtil\getDisplayValues(), FormUtil\getListMap(), Controller\isLocalizedRequest(), BatchDisplayController\loadNode(), and FormUtil\resolveByOid().
Localization::getDefaultLanguage | ( | ) |
Get the default language that is used in the store. Reads the key 'defaultLanguage' in the configuation section 'i18n'.
Definition at line 88 of file class.Localization.php.
References InifileParser\getInstance(), getSupportedLanguages(), and WCMFException\throwEx().
Referenced by deleteLanguage(), deleteTranslation(), loadTranslation(), and saveTranslation().
Localization::getSupportedLanguages | ( | ) |
Get all supported languages.
Definition at line 107 of file class.Localization.php.
References $_supportedLanguages, PersistenceFacade\getInstance(), InifileParser\getInstance(), and WCMFException\throwEx().
Referenced by getDefaultLanguage().
Localization::getTranslationType | ( | ) |
Get the type name of the translation instances.
Definition at line 142 of file class.Localization.php.
References InifileParser\getInstance(), and WCMFException\throwEx().
Referenced by deleteLanguage(), deleteTranslation(), loadTranslation(), saveTranslatedValue(), and saveTranslation().
Localization::getIncludedInputTypes | ( | ) |
Get the input types that are translatable.
Definition at line 155 of file class.Localization.php.
References InifileParser\getInstance(), and WCMFException\throwEx().
Referenced by saveTranslatedValue(), and setTranslatedValue().
& Localization::createTranslationInstance | ( | ) |
Get a newly created instance of the type defined in the key 'type' in the configuration section 'i18n'.
Definition at line 169 of file class.Localization.php.
References ObjectFactory\getInstance().
& Localization::loadTranslatedObject | ( | $oid, | |
$lang, | |||
$useDefaults = true |
|||
) |
Load a single translated object. The object is always loaded with BUILDDEPTH_SINGLE.
oid | The id of the object to load the translation for. |
lang | The language of the translation to load. |
useDefaults | True/False wether to use the default language values for untranslated/empty values or not. Optional, default is true |
Definition at line 183 of file class.Localization.php.
References $lang, BUILDDEPTH_SINGLE, PersistenceFacade\getInstance(), and loadTranslation().
Localization::loadTranslation | ( | & | $object, |
$lang, | |||
$useDefaults = true , |
|||
$recursive = true |
|||
) |
Load a translation of an entity for a specific language.
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 | True/False wether to use the default language values for untranslated/empty values or not. Optional, default is true. |
recursive | True/False wether to load translations for children too or not. Optional, default is true. For recursive use, the object must have a getChildren method. |
Definition at line 201 of file class.Localization.php.
References $lang, BUILDDEPTH_SINGLE, PersistenceFacade\createObjectQuery(), getDefaultLanguage(), getTranslationType(), and WCMFException\throwEx().
Referenced by loadTranslatedObject(), and saveTranslation().
Localization::saveTranslation | ( | & | $object, |
$lang, | |||
$saveEmptyValues = false , |
|||
$recursive = true |
|||
) |
Save a translation of an entity for a specific language. Only the values that have a non-empty value are considered as translations and stored. Only values whose input_type property is listed in the 'inputTypes' key in the configuration 'i18n' are stored.
object | An instance of the entity type that holds the translations as values. |
lang | The language of the translation. |
saveEmptyValues | True/False wether to save empty translations or not. Optional, default is false |
recursive | True/False wether to save translations for children too or not. Optional, default is true. For recursive use, the object must have a getChildren method. |
Definition at line 247 of file class.Localization.php.
References $lang, BUILDDEPTH_SINGLE, PersistenceFacade\createObjectQuery(), getDefaultLanguage(), getTranslationType(), and loadTranslation().
Localization::deleteTranslation | ( | $oid, | |
$lang = null |
|||
) |
Remove translations for a given entity.
oid | The id of the object |
lang | The language of the translation to remove. If null, all translations will be deleted [default: null] |
Definition at line 286 of file class.Localization.php.
References $lang, PersistenceFacade\createObjectQuery(), getDefaultLanguage(), PersistenceFacade\getInstance(), and getTranslationType().
Localization::deleteLanguage | ( | $lang | ) |
Delete all translations for a given language.
lang | The language of the translations to remove |
Definition at line 316 of file class.Localization.php.
References $lang, PersistenceFacade\createObjectQuery(), getDefaultLanguage(), PersistenceFacade\getInstance(), and getTranslationType().
Localization::setTranslatedValue | ( | & | $obj, |
$valueName, | |||
$dataType, | |||
& | $translations, | ||
$useDefaults | |||
) |
Callback for setting translated values in the given object
Definition at line 343 of file class.Localization.php.
References DATATYPE_ATTRIBUTE, DATATYPE_IGNORE, and getIncludedInputTypes().
Localization::saveTranslatedValue | ( | & | $obj, |
$valueName, | |||
$dataType, | |||
& | $existingTranslations, | ||
$lang, | |||
$saveEmptyValues | |||
) |
Callback for saving translated values for the given object
Definition at line 372 of file class.Localization.php.
References $lang, DATATYPE_IGNORE, getIncludedInputTypes(), PersistenceFacade\getInstance(), and getTranslationType().
Localization::$_supportedLanguages = null |
Definition at line 67 of file class.Localization.php.
Referenced by getSupportedLanguages().