Elgg  Version 1.11
Public Member Functions | List of all members
Elgg\I18n\Translator Class Reference

WARNING: API IN FLUX. More...

Inheritance diagram for Elgg\I18n\Translator:
Elgg\I18n\NullTranslator

Public Member Functions

 __construct ()
 Initializes new translator. More...
 
 translate ($message_key, $args=array(), $language="")
 Given a message key, returns an appropriately translated full-text string. More...
 
 addTranslation ($country_code, $language_array)
 Add a translation. More...
 
 getCurrentLanguage ()
 Detect the current language being used by the current site or logged in user. More...
 
 getLanguage ()
 Gets the current language in use by the system or user. More...
 
 loadTranslations ()
 private More...
 
 registerTranslations ($path, $load_all=false)
 When given a full path, finds translation files and loads them. More...
 
 reloadAllTranslations ()
 Reload all translations from all registered paths. More...
 
 getInstalledTranslations ()
 Return an array of installed translations as an associative array "two letter code" => "native language name". More...
 
 getLanguageCompleteness ($language)
 Return the level of completeness for a given language code (compared to english) More...
 
 getMissingLanguageKeys ($language)
 Return the translation keys missing from a given language, or those that are identical to the english version. More...
 
 languageKeyExists ($key, $language= 'en')
 Check if a give language key exists. More...
 
 getAllLanguageCodes ()
 Returns an array of language codes. More...
 

Detailed Description

WARNING: API IN FLUX.

DO NOT USE DIRECTLY.

private

Since
1.10.0

Definition at line 11 of file Translator.php.

Constructor & Destructor Documentation

Elgg\I18n\Translator::__construct ( )

Initializes new translator.

Definition at line 23 of file Translator.php.

Member Function Documentation

Elgg\I18n\Translator::addTranslation (   $country_code,
  $language_array 
)

Add a translation.

Translations are arrays in the Zend Translation array format, eg:

$english = array('message1' => 'message1', 'message2' => 'message2'); $german = array('message1' => 'Nachricht1','message2' => 'Nachricht2');

Parameters
string$country_codeStandard country code (eg 'en', 'nl', 'es')
array$language_arrayFormatted array of strings
Returns
bool Depending on success

Definition at line 108 of file Translator.php.

Elgg\I18n\Translator::getAllLanguageCodes ( )

Returns an array of language codes.

Returns
array

Definition at line 424 of file Translator.php.

Elgg\I18n\Translator::getCurrentLanguage ( )

Detect the current language being used by the current site or logged in user.

Returns
string The language code for the site/user or "en" if not set

Definition at line 134 of file Translator.php.

Elgg\I18n\Translator::getInstalledTranslations ( )

Return an array of installed translations as an associative array "two letter code" => "native language name".

Returns
array

Definition at line 310 of file Translator.php.

Elgg\I18n\Translator::getLanguage ( )

Gets the current language in use by the system or user.

Returns
string The language code (eg "en") or false if not set

Definition at line 149 of file Translator.php.

Elgg\I18n\Translator::getLanguageCompleteness (   $language)

Return the level of completeness for a given language code (compared to english)

Parameters
string$languageLanguage
Returns
int

Definition at line 340 of file Translator.php.

Elgg\I18n\Translator::getMissingLanguageKeys (   $language)

Return the translation keys missing from a given language, or those that are identical to the english version.

Parameters
string$languageThe language
Returns
mixed

Definition at line 371 of file Translator.php.

Elgg\I18n\Translator::languageKeyExists (   $key,
  $language = 'en' 
)

Check if a give language key exists.

Parameters
string$keyThe translation key
string$languageThe specific language to check
Returns
bool
Since
1.11

Definition at line 402 of file Translator.php.

Elgg\I18n\Translator::loadTranslations ( )

private

Definition at line 176 of file Translator.php.

Elgg\I18n\Translator::registerTranslations (   $path,
  $load_all = false 
)

When given a full path, finds translation files and loads them.

Parameters
string$pathFull path
bool$load_allIf true all languages are loaded, if false only the current language + en are loaded
Returns
bool success

Definition at line 214 of file Translator.php.

Elgg\I18n\Translator::reloadAllTranslations ( )

Reload all translations from all registered paths.

This is only called by functions which need to know all possible translations.

Returns
void

Definition at line 271 of file Translator.php.

Elgg\I18n\Translator::translate (   $message_key,
  $args = array(),
  $language = "" 
)

Given a message key, returns an appropriately translated full-text string.

Parameters
string$message_keyThe short message code
array$argsAn array of arguments to pass through vsprintf().
string$languageOptionally, the standard language code (defaults to site/user default, then English)
Returns
string Either the translated string, the English string, or the original language string.

Definition at line 40 of file Translator.php.


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