Elgg  Version 5.1
i18n.js
Go to the documentation of this file.
1 define(['jquery', 'elgg', 'sprintf'], function ($, elgg, sprintf) {
2 
3  var translations_data = [];
4 
5  return {
9  reset: function() {
10  translations_data = [];
11  },
12 
18  initLanguage: function(language) {
19  language = language || elgg.config.current_language;
20 
21  if (typeof translations_data[language] !== 'undefined') {
22  // only init a language once
23  return;
24  }
25 
26  $.ajax({
27  url: elgg.get_simplecache_url('languages/' + language + '.js'),
28  dataType: 'json',
29  async: false,
30  success: function(translations) {
31  translations_data[language] = translations;
32  }
33  });
34  },
35 
43  addTranslation: function(lang, translations) {
44  if (typeof translations_data[lang] === 'undefined') {
45  translations_data[lang] = {};
46  }
47 
48  $.extend(translations_data[lang], translations);
49  },
50 
60  echo: function(key, argv, language) {
61  //echo('str', 'en')
62  if (typeof argv === 'string') {
63  language = argv;
64  argv = [];
65  }
66 
67  this.initLanguage(language);
68 
69  //echo('str', [...], 'en')
70  var dlang = elgg.config.current_language;
71 
72  language = language || dlang;
73  argv = argv || [];
74 
75  var map = translations_data[language] || translations_data[dlang];
76  if (map && (typeof map[key] === 'string')) {
77  return sprintf.vsprintf(map[key], argv);
78  }
79 
80  return key;
81  }
82  };
83 });
define(['jquery', 'elgg', 'sprintf'], function($, elgg, sprintf){var translations_data=[];return{reset:function(){translations_data=[];}, initLanguage:function(language){language=language||elgg.config.current_language;if(typeof translations_data[language]!== 'undefined'){return;}$.ajax({url:elgg.get_simplecache_url('languages/'+language+ '.js'), dataType: 'json', async:false, success:function(translations){translations_data[language]=translations;}});}, addTranslation:function(lang, translations){if(typeof translations_data[lang]=== 'undefined'){translations_data[lang]={};}$.extend(translations_data[lang], translations);}, echo:function(key, argv, language){if(typeof argv=== 'string'){language=argv;argv=[];}this.initLanguage(language);var dlang=elgg.config.current_language;language=language||dlang;argv=argv||[];var map=translations_data[language]||translations_data[dlang];if(map &&(typeof map[key]=== 'string')){return sprintf.vsprintf(map[key], argv);}return key;}};})
var elgg
Definition: elgglib.js:4
Bundled plugins(the contents of the"/mod"directory) are available only under the GPLv2 license.The remainder of the project is available under either MIT or GPLv2.Both licenses can be found below.More info and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of either verbatim or with modifications and or translated into another language(Hereinafter, translation is included without limitation in the term"modification".) Each licensee is addressed as"you".Activities other than copying