Elgg
Version 2.3
|
WARNING: API IN FLUX. More...
Public Member Functions | |
__construct () | |
Initializes new translator. More... | |
translate ($message_key, $args=[], $language="") | |
Given a message key, returns an appropriately translated full-text string. More... | |
addTranslation ($country_code, $language_array) | |
Add a translation. More... | |
getCurrentLanguage () | |
Get the current system/user language or "en". More... | |
detectLanguage () | |
Detect the current system/user language or false. More... | |
loadTranslations ($language=null) | |
Load both core and plugin translations. More... | |
registerPluginTranslations ($path) | |
Registers translations in a directory assuming the standard plugin layout. More... | |
registerTranslations ($path, $load_all=false, $language=null) | |
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 given language key exists. More... | |
Static Public Member Functions | |
static | getAllLanguageCodes () |
Returns an array of language codes. More... | |
static | normalizeLanguageCode ($code) |
Normalize a language code (e.g. More... | |
WARNING: API IN FLUX.
DO NOT USE DIRECTLY.
private
Definition at line 11 of file Translator.php.
Elgg\I18n\Translator::__construct | ( | ) |
Initializes new translator.
Definition at line 23 of file Translator.php.
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');
string | $country_code | Standard country code (eg 'en', 'nl', 'es') |
array | $language_array | Formatted array of strings |
Definition at line 118 of file Translator.php.
Elgg\I18n\Translator::detectLanguage | ( | ) |
Detect the current system/user language or false.
Definition at line 159 of file Translator.php.
|
static |
Elgg\I18n\Translator::getCurrentLanguage | ( | ) |
Get the current system/user language or "en".
Definition at line 144 of file Translator.php.
Elgg\I18n\Translator::getInstalledTranslations | ( | ) |
Return an array of installed translations as an associative array "two letter code" => "native language name".
Definition at line 410 of file Translator.php.
Elgg\I18n\Translator::getLanguageCompleteness | ( | $language | ) |
Return the level of completeness for a given language code (compared to english)
string | $language | Language |
Definition at line 449 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.
string | $language | The language |
Definition at line 480 of file Translator.php.
Elgg\I18n\Translator::languageKeyExists | ( | $key, | |
$language = 'en' |
|||
) |
Check if a given language key exists.
string | $key | The translation key |
string | $language | The specific language to check |
Definition at line 511 of file Translator.php.
Elgg\I18n\Translator::loadTranslations | ( | $language = null | ) |
Load both core and plugin translations.
By default this loads only English and the language of the logged in user.
The optional $language argument can be used to load translations on-demand in case we need to translate something to a language not loaded by default for the current request.
string | $language | Language code private |
Definition at line 196 of file Translator.php.
|
static |
Normalize a language code (e.g.
from Transifex)
string | $code | Language code |
Definition at line 710 of file Translator.php.
Elgg\I18n\Translator::registerPluginTranslations | ( | $path | ) |
Registers translations in a directory assuming the standard plugin layout.
string | $path | Without the trailing slash. |
Definition at line 288 of file Translator.php.
Elgg\I18n\Translator::registerTranslations | ( | $path, | |
$load_all = false , |
|||
$language = null |
|||
) |
When given a full path, finds translation files and loads them.
string | $path | Full path |
bool | $load_all | If true all languages are loaded, if false only the current language + en are loaded |
string | $language | Language code |
Definition at line 309 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.
Definition at line 371 of file Translator.php.
Elgg\I18n\Translator::translate | ( | $message_key, | |
$args = [] , |
|||
$language = "" |
|||
) |
Given a message key, returns an appropriately translated full-text string.
string | $message_key | The short message code |
array | $args | An array of arguments to pass through vsprintf(). |
string | $language | Optionally, the standard language code (defaults to site/user default, then English) |
Definition at line 40 of file Translator.php.