seitime-frappe/public/js/wn/translate.js
2013-09-22 08:28:39 +02:00

18 lines
536 B
JavaScript

// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
// MIT License. See license.txt
// for translation
wn._messages = {};
wn._ = function(txt, replace) {
if(!txt) return txt;
if(typeof(txt) != "string") return txt;
preformat = wn._messages[txt.replace(/\n/g, "")] || txt;
if(!replace) return preformat;
if(replace instanceof Array) return vsprintf(preformat, replace);
return repl(preformat, replace);
};
wn.translate = function(obj, keys) {
$.each(keys, function(i, key) {
obj["_" + key] = wn._(obj[key]);
})
}