Elgg  Version 3.0
Functions | Variables
languages.js File Reference

Go to the source code of this file.


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


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);
var elgg
Definition: elgglib.js:4

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(),
language = language || dlang;
argv = argv || [];
map = translations[language] || translations[dlang];
if (map && elgg.isString(map[key])) {
return vsprintf(map[key], argv);
return key;
elgg config language
Definition: languages.js:8
var elgg
Definition: elgglib.js:4

Translates a string.

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.
{String}key Message key
{Array}argv vsprintf() arguments
{String}language Requested language. Not recommended (see above).
{String} The translation or the given key if no translation available

Definition at line 43 of file languages.js.

elgg get_language
Initial value:
= function() {
return elgg.config.current_language;
var elgg
Definition: elgglib.js:4

Get the current language.


Definition at line 24 of file languages.js.

elgg config language = 'en'

Definition at line 8 of file languages.js.