Localization Interface Reference

Detailed Description

Localization defines the interface for storing localized entity instances and retrieving them back.

Localization is done against a default language. This means that all entity data in the store is supposed to use the default language except those data stored as translations. Translations maybe done in all supported languages.

Language names may conform to ISO 639 language codes, but this is not mandatory. One of the supported languages must be equal to the value of default language.

Generally only values are translatable.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 32 of file Localization.php.

+ Inheritance diagram for Localization:

Public Member Functions

 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)
 

Member Function Documentation

◆ getDefaultLanguage()

getDefaultLanguage ( )

Get the default language that is used in the store.

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

Implemented in DefaultLocalization.

◆ getSupportedLanguages()

getSupportedLanguages ( )

Get all supported languages.

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

Implemented in DefaultLocalization.

◆ loadTranslatedObject()

loadTranslatedObject ( ObjectId  $oid,
  $lang,
  $useDefaults = true 
)

Load a single translated object.

The object is always loaded with BuildDepth::SINGLE.

Parameters
$oidThe object id of the object to load the translation for.
$langThe language of the translation to load.
$useDefaultsBoolean whether to use the default language values for untranslated/empty values or not. Optional, default is true
Returns
PersistentObject

Implemented in DefaultLocalization.

◆ loadTranslation()

loadTranslation ( PersistentObject  $object,
  $lang,
  $useDefaults = true,
  $recursive = true 
)

Load a translation of an entity for a specific language.

Parameters
$objectThe PersistentObject instance 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.
$useDefaultsBoolean whether to use the default language values for untranslated/empty values or not. Optional, default is true.
$recursiveBoolean whether to load translations for children too or not. Optional, default is true. For recursive use, the object must have a getChildren method.
Returns
PersistentObject

◆ saveTranslation()

saveTranslation ( PersistentObject  $object,
  $lang,
  $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.

Parameters
$objectAn instance of the entity type that holds the translations as values.
$langThe language of the translation.
$recursiveBoolean whether to save translations for children too or not. Optional, default is true. For recursive use, the object must have a getChildren method.

Implemented in DefaultLocalization.

◆ deleteTranslation()

deleteTranslation ( ObjectId  $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)

Implemented in DefaultLocalization.

◆ deleteLanguage()

deleteLanguage (   $lang)

Delete all translations for a given language.

Parameters
$langThe language of the translations to remove

Implemented in DefaultLocalization.