mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #1743 from node-red-hitachi/0.19-allow-i18n-translation-in-runtime
Allow i18n translation in runtime
This commit is contained in:
commit
4cfbf7f71c
@ -81,16 +81,32 @@ var MessageFileLoader = {
|
||||
|
||||
}
|
||||
|
||||
function getCurrentLocale() {
|
||||
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 = getCurrentLocale();
|
||||
if (lang) {
|
||||
opt.lng = lang;
|
||||
}
|
||||
i18n.init(opt ,function() {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user