mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
allow i18n translation in runtime
This commit is contained in:
parent
0ff0f25aaf
commit
0ad54cc2d1
@ -81,16 +81,32 @@ var MessageFileLoader = {
|
||||
|
||||
}
|
||||
|
||||
function current_locale() {
|
||||
var env = process.env;
|
||||
for (var name of ['LC_ALL', 'LC_MESSAGES', 'LANG']) {
|
||||
if (name in env) {
|
||||
var val = env[name];
|
||||
return val.substring(0, 2);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function init() {
|
||||
return when.promise(function(resolve,reject) {
|
||||
i18n.backend(MessageFileLoader);
|
||||
i18n.init({
|
||||
var opt = {
|
||||
ns: {
|
||||
namespaces: [],
|
||||
defaultNs: "runtime"
|
||||
},
|
||||
fallbackLng: [defaultLang]
|
||||
},function() {
|
||||
};
|
||||
var lang = current_locale();
|
||||
if (lang) {
|
||||
opt.lng = lang;
|
||||
}
|
||||
i18n.init(opt ,function() {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user