wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
Localization Class Reference

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
 

Detailed Description

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.

Id:
class.Localization.php 929 2009-02-22 23:20:49Z iherwig

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.

Note
: Localization is not aware of value datatypes. That means if an entity has two values with the same name, but different datatype, localization behaviour is not defined for these two values.
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 65 of file class.Localization.php.

Member Function Documentation

Localization::getDefaultLanguage ( )

Get the default language that is used in the store. Reads the key 'defaultLanguage' in the configuation section 'i18n'.

Returns
The default language value (e.g. en)

Definition at line 88 of file class.Localization.php.

References InifileParser\getInstance(), getSupportedLanguages(), and WCMFException\throwEx().

Referenced by deleteLanguage(), deleteTranslation(), loadTranslation(), and saveTranslation().

+ Here is the call graph for this function:

Localization::getSupportedLanguages ( )

Get all supported languages.

Returns
An associative array with the language codes as keys and the names as values.

Definition at line 107 of file class.Localization.php.

References $_supportedLanguages, PersistenceFacade\getInstance(), InifileParser\getInstance(), and WCMFException\throwEx().

Referenced by getDefaultLanguage().

+ Here is the call graph for this function:

Localization::getTranslationType ( )

Get the type name of the translation instances.

Returns
The type name.

Definition at line 142 of file class.Localization.php.

References InifileParser\getInstance(), and WCMFException\throwEx().

Referenced by deleteLanguage(), deleteTranslation(), loadTranslation(), saveTranslatedValue(), and saveTranslation().

+ Here is the call graph for this function:

Localization::getIncludedInputTypes ( )

Get the input types that are translatable.

Returns
The input type names.

Definition at line 155 of file class.Localization.php.

References InifileParser\getInstance(), and WCMFException\throwEx().

Referenced by saveTranslatedValue(), and setTranslatedValue().

+ Here is the call graph for this function:

& Localization::createTranslationInstance ( )

Get a newly created instance of the type defined in the key 'type' in the configuration section 'i18n'.

Returns
An instance.

Definition at line 169 of file class.Localization.php.

References ObjectFactory\getInstance().

+ Here is the call graph for this function:

& Localization::loadTranslatedObject (   $oid,
  $lang,
  $useDefaults = true 
)

Load a single translated object. The object is always loaded with BUILDDEPTH_SINGLE.

Parameters
oidThe id of the object to load the translation for.
langThe language of the translation to load.
useDefaultsTrue/False wether to use the default language values for untranslated/empty values or not. Optional, default is true
Returns
A reference to the translated object.

Definition at line 183 of file class.Localization.php.

References $lang, BUILDDEPTH_SINGLE, PersistenceFacade\getInstance(), and loadTranslation().

+ Here is the call graph for this function:

Localization::loadTranslation ( $object,
  $lang,
  $useDefaults = true,
  $recursive = true 
)

Load a translation of an entity for a specific language.

Parameters
objectA reference to the object to load the translation into. The object is supposed to have it's values in the default language.
langThe language of the translation to load.
useDefaultsTrue/False wether to use the default language values for untranslated/empty values or not. Optional, default is true.
recursiveTrue/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().

+ Here is the call graph for this function:

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.

Parameters
objectAn instance of the entity type that holds the translations as values.
langThe language of the translation.
saveEmptyValuesTrue/False wether to save empty translations or not. Optional, default is false
recursiveTrue/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().

+ Here is the call graph for this function:

Localization::deleteTranslation (   $oid,
  $lang = null 
)

Remove translations for a given entity.

Parameters
oidThe id of the object
langThe 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().

+ Here is the call graph for this function:

Localization::deleteLanguage (   $lang)

Delete all translations for a given language.

Parameters
langThe language of the translations to remove

Definition at line 316 of file class.Localization.php.

References $lang, PersistenceFacade\createObjectQuery(), getDefaultLanguage(), PersistenceFacade\getInstance(), and getTranslationType().

+ Here is the call graph for this function:

Localization::setTranslatedValue ( $obj,
  $valueName,
  $dataType,
$translations,
  $useDefaults 
)

Callback for setting translated values in the given object

See Also
NodeProcessor

Definition at line 343 of file class.Localization.php.

References DATATYPE_ATTRIBUTE, DATATYPE_IGNORE, and getIncludedInputTypes().

+ Here is the call graph for this function:

Localization::saveTranslatedValue ( $obj,
  $valueName,
  $dataType,
$existingTranslations,
  $lang,
  $saveEmptyValues 
)

Callback for saving translated values for the given object

See Also
NodeProcessor

Definition at line 372 of file class.Localization.php.

References $lang, DATATYPE_IGNORE, getIncludedInputTypes(), PersistenceFacade\getInstance(), and getTranslationType().

+ Here is the call graph for this function:

Member Data Documentation

Localization::$_supportedLanguages = null

Definition at line 67 of file class.Localization.php.

Referenced by getSupportedLanguages().


The documentation for this class was generated from the following file: