Elgg  Version 3.0
Namespaces | Functions
languages.php File Reference

Go to the source code of this file.

Namespaces

 Elgg\Core
 Updates the advanced settings for the primary site object.
 

Functions

 elgg_echo ($message_key, array $args=[], $language="")
 Given a message key, returns an appropriately translated full-text string. More...
 
 add_translation ($country_code, $language_array)
 Add a translation. More...
 
 get_current_language ()
 Get the current system/user language or "en". More...
 
 get_language ()
 Detect the current system/user language or false. More...
 
 get_installed_translations ($calculate_completeness=false)
 Return an array of installed translations as an associative array "two letter code" => "native language name". More...
 
 get_language_completeness ($language)
 Return the level of completeness for a given language code (compared to english) More...
 
 elgg_language_key_exists ($key, $language= 'en')
 Check if a given language key exists. More...
 
 elgg_get_available_languages ()
 Returns an array of available languages. More...
 

Function Documentation

add_translation (   $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 38 of file languages.php.

elgg_echo (   $message_key,
array  $args = [],
  $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.
Examples:
/root/Elgg/engine/lib/output.php, and /root/Elgg/engine/lib/views.php.

Definition at line 21 of file languages.php.

elgg_get_available_languages ( )

Returns an array of available languages.

Returns
array
Since
3.0

Definition at line 106 of file languages.php.

elgg_language_key_exists (   $key,
  $language = 'en' 
)

Check if a given language key exists.

Note
Translators should, whenever creating a "dynamically" named language key, always create an English (fallback) translation as well.
Parameters
string$keyThe translation key
string$languageThe language. Provided an English translation exists for all created keys, then devs can generally use the default "en", regardless of the site/user language.
Returns
bool
Since
1.11

Definition at line 96 of file languages.php.

get_current_language ( )

Get the current system/user language or "en".

Returns
string The language code for the site/user or "en" if not set
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 47 of file languages.php.

get_installed_translations (   $calculate_completeness = false)

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

Parameters
boolean$calculate_completenessSet to true if you want a completeness postfix added to the language text
Returns
array

Definition at line 68 of file languages.php.

get_language ( )

Detect the current system/user language or false.

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

Definition at line 56 of file languages.php.

get_language_completeness (   $language)

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

Parameters
string$languageLanguage
Returns
int

Definition at line 79 of file languages.php.