Elgg  Version 2.2
Functions | Variables
languages.js File Reference

Go to the source code of this file.

Functions

elgg provide ('elgg.config.translations')
 Provides language-related functionality. More...
 

Variables

elgg config language = 'en'
 
elgg add_translation
 Analagous to the php version. More...
 
elgg get_language
 Get the current language. More...
 
elgg echo
 Translates a string. More...
 

Function Documentation

elgg provide ( 'elgg.config.translations )

Provides language-related functionality.

Variable Documentation

elgg add_translation
Initial value:
= function(lang, translations) {
elgg.provide('elgg.config.translations.' + lang);
elgg.extend(elgg.config.translations[lang], translations);
}
elgg
Definition: install.js:23
$_ELGG translations
String translations for the current language.
Definition: config.php:321

Analagous to the php version.

Merges translations for a given language into the current translations map.

Definition at line 14 of file languages.js.

elgg echo
Initial value:
= function(key, argv, language) {
if (elgg.isString(argv)) {
language = argv;
argv = [];
}
var translations = elgg.config.translations,
dlang = elgg.get_language(),
map;
language = language || dlang;
argv = argv || [];
map = translations[language] || translations[dlang];
if (map && elgg.isString(map[key])) {
return vsprintf(map[key], argv);
}
return key;
}
elgg
Definition: install.js:23
$_ELGG translations
String translations for the current language.
Definition: config.php:321
elgg config language
Definition: languages.js:8
var vsprintf
Definition: sprintf.js:180

Translates a string.

Note
The current system only loads a single language module per page, and it comes pre-merged with English translations. Hence, elgg.echo() can only return translations in the language returned by elgg.get_language(). Requests for other languages will fail unless a 3rd party plugin has manually used elgg.add_translation() to merge the language module ahead of time.
Parameters
{String}key Message key
{Array}argv vsprintf() arguments
{String}language Requested language. Not recommended (see above).
Returns
{String} The translation or the given key if no translation available

Definition at line 48 of file languages.js.

elgg get_language
Initial value:
= function() {
var user = elgg.get_logged_in_user_entity();
if (user && user.language) {
return user.language;
}
return elgg.config.language;
}
elgg
Definition: install.js:23
elgg menu user
Definition: admin.css.php:192

Get the current language.

Returns
{String}

Definition at line 24 of file languages.js.

elgg config language = 'en'

Definition at line 8 of file languages.js.