kivitendo/js/kivi.js @ 670f1111
224291dd | Thomas Heck | namespace("kivi", function(ns) {
|
||
440ad8d3 | Thomas Heck | ns._locale = {};
|
||
224291dd | Thomas Heck | |||
ns.t8 = function(text, params) {
|
||||
440ad8d3 | Thomas Heck | var text = ns._locale[text] || text;
|
||
224291dd | Thomas Heck | |||
if( Object.prototype.toString.call( params ) === '[object Array]' ) {
|
||||
var len = params.length;
|
||||
for(var i=0; i<len; ++i) {
|
||||
var key = i + 1;
|
||||
var value = params[i];
|
||||
text = text.split("#"+ key).join(value);
|
||||
}
|
||||
}
|
||||
else if( typeof params == 'object' ) {
|
||||
for(var key in params) {
|
||||
var value = params[key];
|
||||
text = text.split("#{"+ key +"}").join(value);
|
||||
}
|
||||
}
|
||||
return text;
|
||||
};
|
||||
440ad8d3 | Thomas Heck | ns.setupLocale = function(locale) {
|
||
ns._locale = locale;
|
||||
224291dd | Thomas Heck | };
|
||
});
|
||||
440ad8d3 | Thomas Heck | |||
kivi = namespace('kivi');
|