Elgg  Version 3.0
languages.js
Go to the documentation of this file.
1 /*globals vsprintf*/
5 elgg.provide('elgg.config.translations');
6 
7 // default language - required by unit tests
8 elgg.config.language = 'en';
9 
14 elgg.add_translation = function(lang, translations) {
15  elgg.provide('elgg.config.translations.' + lang);
16 
17  elgg.extend(elgg.config.translations[lang], translations);
18 };
19 
24 elgg.get_language = function() {
25  // set by _elgg_get_js_page_data()
26  return elgg.config.current_language;
27 };
28 
43 elgg.echo = function(key, argv, language) {
44  //elgg.echo('str', 'en')
45  if (elgg.isString(argv)) {
46  language = argv;
47  argv = [];
48  }
49 
50  //elgg.echo('str', [...], 'en')
51  var translations = elgg.config.translations,
52  dlang = elgg.get_language(),
53  map;
54 
55  language = language || dlang;
56  argv = argv || [];
57 
58  map = translations[language] || translations[dlang];
59  if (map && elgg.isString(map[key])) {
60  return vsprintf(map[key], argv);
61  }
62 
63  return key;
64 };
65 
elgg config language
Definition: languages.js:8
var elgg
Definition: elgglib.js:4