ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
|
Public Member Functions | |
__construct (\SimpleSAML_Configuration $configuration, $defaultDictionary=null) | |
Constructor. More... | |
getLanguage () | |
Return the internal language object used by this translator. More... | |
getTag ($tag) | |
This method retrieves a tag as an array with language => string mappings. More... | |
getPreferredTranslation ($translations) | |
Retrieve the preferred translation of a given text. More... | |
getAttributeTranslation ($name) | |
Translate the name of an attribute. More... | |
t ( $tag, $replacements=array(), $fallbackdefault=true, $oldreplacements=array(), $striptags=false) | |
Translate a tag into the current language, with a fallback to english. More... | |
includeInlineTranslation ($tag, $translation) | |
Include a translation inline instead of putting translations in dictionaries. More... | |
includeLanguageFile ($file, $otherConfig=null) | |
Include a language file from the dictionaries directory. More... | |
Static Public Member Functions | |
static | noop ($tag) |
Mark a string for translation without translating it. More... | |
static | translateSingularGettext ($original) |
static | translatePluralGettext ($original, $plural, $value) |
static | translateFromArray ($context, $translations) |
Pick a translation from a given array of translations for the current language. More... | |
Private Member Functions | |
getDictionary ($name) | |
This method retrieves a dictionary with the name given. More... | |
getStringNotTranslated ($tag, $fallbacktag) | |
Return the string that should be used when no translation was found. More... | |
readDictionaryJSON ($filename) | |
Read a dictionary file in JSON format. More... | |
readDictionaryPHP ($filename) | |
Read a dictionary file in PHP format. More... | |
readDictionaryFile ($filename) | |
Read a dictionary file. More... | |
Private Attributes | |
$configuration | |
$langtext = array() | |
$dictionaries = array() | |
Associative array of dictionaries. More... | |
$defaultDictionary = null | |
The default dictionary. More... | |
$language | |
Definition at line 13 of file Translate.php.
SimpleSAML\Locale\Translate::__construct | ( | \SimpleSAML_Configuration | $configuration, |
$defaultDictionary = null |
|||
) |
Constructor.
\SimpleSAML_Configuration | $configuration | Configuration object |
string | null | $defaultDictionary | The default dictionary where tags will come from. |
Definition at line 49 of file Translate.php.
References SimpleSAML\Locale\Translate\$configuration, SimpleSAML\Locale\Translate\$defaultDictionary, and SimpleSAML\Logger\warning().
SimpleSAML\Locale\Translate::getAttributeTranslation | ( | $name | ) |
Translate the name of an attribute.
string | $name | The attribute name. |
Definition at line 198 of file Translate.php.
References $name, SimpleSAML\Locale\Translate\getDictionary(), and SimpleSAML\Locale\Translate\getPreferredTranslation().
|
private |
This method retrieves a dictionary with the name given.
string | $name | The name of the dictionary, as the filename in the dictionary directory, without the '.php' ending. |
Definition at line 90 of file Translate.php.
References $module, $name, SimpleSAML\Module\getModuleDir(), and SimpleSAML\Locale\Translate\readDictionaryFile().
Referenced by SimpleSAML\Locale\Translate\getAttributeTranslation(), and SimpleSAML\Locale\Translate\getTag().
SimpleSAML\Locale\Translate::getLanguage | ( | ) |
Return the internal language object used by this translator.
Definition at line 76 of file Translate.php.
References SimpleSAML\Locale\Translate\$language.
SimpleSAML\Locale\Translate::getPreferredTranslation | ( | $translations | ) |
Retrieve the preferred translation of a given text.
array | $translations | The translations, as an associative array with language => text mappings. |
Definition at line 159 of file Translate.php.
References $languages.
Referenced by SimpleSAML\Locale\Translate\getAttributeTranslation(), and SimpleSAML\Locale\Translate\t().
|
private |
Return the string that should be used when no translation was found.
string | $tag | A name tag of the string that should be returned. |
boolean | $fallbacktag | If set to true and string was not found in any languages, return the tag itself. If false return null. |
Definition at line 335 of file Translate.php.
References $tag.
Referenced by SimpleSAML\Locale\Translate\t().
SimpleSAML\Locale\Translate::getTag | ( | $tag | ) |
This method retrieves a tag as an array with language => string mappings.
string | $tag | The tag name. The tag name can also be on the form '{<dictionary>:<tag>}', to retrieve a tag from the specific dictionary. |
Definition at line 120 of file Translate.php.
References SimpleSAML\Locale\Translate\$defaultDictionary, $tag, and SimpleSAML\Locale\Translate\getDictionary().
Referenced by SimpleSAML\Locale\Translate\t().
SimpleSAML\Locale\Translate::includeInlineTranslation | ( | $tag, | |
$translation | |||
) |
Include a translation inline instead of putting translations in dictionaries.
This function is recommended to be used ONLU from variable data, or when the translation is already provided by an external source, as a database or in metadata.
string | $tag | The tag that has a translation |
array | string | $translation | The translation array |
Definition at line 355 of file Translate.php.
References $tag, and SimpleSAML\Logger\debug().
SimpleSAML\Locale\Translate::includeLanguageFile | ( | $file, | |
$otherConfig = null |
|||
) |
Include a language file from the dictionaries directory.
string | $file | File name of dictionary to include |
\SimpleSAML_Configuration | null | $otherConfig | Optionally provide a different configuration object than the one provided in the constructor to be used to find the directory of the dictionary. This allows to combine dictionaries inside the SimpleSAMLphp main code distribution together with external dictionaries. Defaults to null. |
Definition at line 377 of file Translate.php.
References $lang, SimpleSAML\Logger\debug(), and SimpleSAML\Locale\Translate\readDictionaryFile().
|
static |
Mark a string for translation without translating it.
string | $tag | A tag name to mark for translation. |
Definition at line 231 of file Translate.php.
References $tag.
|
private |
Read a dictionary file.
string | $filename | The absolute path to the dictionary file. |
Definition at line 453 of file Translate.php.
References $_SERVER, $filename, SimpleSAML\Logger\debug(), SimpleSAML\Logger\error(), SimpleSAML\Locale\Translate\readDictionaryJSON(), and SimpleSAML\Locale\Translate\readDictionaryPHP().
Referenced by SimpleSAML\Locale\Translate\getDictionary(), and SimpleSAML\Locale\Translate\includeLanguageFile().
|
private |
Read a dictionary file in JSON format.
string | $filename | The absolute path to the dictionary file, minus the .definition.json ending. |
Definition at line 398 of file Translate.php.
References $filename, $lang, and SimpleSAML\Logger\error().
Referenced by SimpleSAML\Locale\Translate\readDictionaryFile().
|
private |
Read a dictionary file in PHP format.
string | $filename | The absolute path to the dictionary file. |
Definition at line 431 of file Translate.php.
References $filename, and $lang.
Referenced by SimpleSAML\Locale\Translate\readDictionaryFile().
SimpleSAML\Locale\Translate::t | ( | $tag, | |
$replacements = array() , |
|||
$fallbackdefault = true , |
|||
$oldreplacements = array() , |
|||
$striptags = false |
|||
) |
Translate a tag into the current language, with a fallback to english.
This function is used to look up a translation tag in dictionaries, and return the translation into the current language. If no translation into the current language can be found, english will be tried, and if that fails, placeholder text will be returned.
An array can be passed as the tag. In that case, the array will be assumed to be on the form (language => text), and will be used as the source of translations.
This function can also do replacements into the translated tag. It will search the translated tag for the keys provided in $replacements, and replace any found occurrences with the value of the key.
string | array | $tag | A tag name for the translation which should be looked up, or an array with (language => text) mappings. The array version will go away in 2.0 |
array | $replacements | An associative array of keys that should be replaced with values in the translated string. |
boolean | $fallbackdefault | Default translation to use as a fallback if no valid translation was found. |
Definition at line 259 of file Translate.php.
References $tag, SimpleSAML\Locale\Translate\getPreferredTranslation(), SimpleSAML\Locale\Translate\getStringNotTranslated(), SimpleSAML\Locale\Translate\getTag(), SimpleSAML\Logger\info(), and SimpleSAML\Logger\warning().
|
static |
Pick a translation from a given array of translations for the current language.
array | $context | An array of options. The current language must be specified as an ISO 639 code accessible with the key "currentLanguage" in the array. |
array | $translations | An array of translations. Each translation has an ISO 639 code as its key, identifying the language it corresponds to. |
Definition at line 515 of file Translate.php.
References $context, $lang, and SimpleSAML_Configuration\getInstance().
|
static |
Definition at line 490 of file Translate.php.
References Gettext\BaseTranslator\$current, and $text.
|
static |
Definition at line 476 of file Translate.php.
References Gettext\BaseTranslator\$current, and $text.
|
private |
Definition at line 21 of file Translate.php.
Referenced by SimpleSAML\Locale\Translate\__construct().
|
private |
The default dictionary.
Definition at line 33 of file Translate.php.
Referenced by SimpleSAML\Locale\Translate\__construct(), and SimpleSAML\Locale\Translate\getTag().
|
private |
Associative array of dictionaries.
Definition at line 28 of file Translate.php.
|
private |
Definition at line 23 of file Translate.php.
|
private |
Definition at line 40 of file Translate.php.
Referenced by SimpleSAML\Locale\Translate\getLanguage().