mirror of
https://github.com/node-red/node-red
synced 2024-11-21 15:43:16 +00:00
parent
c021b4c368
commit
0d0459d83d
@ -208,7 +208,9 @@ module.exports = function(grunt) {
|
|||||||
"node_modules/marked/marked.min.js",
|
"node_modules/marked/marked.min.js",
|
||||||
"node_modules/dompurify/dist/purify.min.js",
|
"node_modules/dompurify/dist/purify.min.js",
|
||||||
"packages/node_modules/@node-red/editor-client/src/vendor/d3/d3.v3.min.js",
|
"packages/node_modules/@node-red/editor-client/src/vendor/d3/d3.v3.min.js",
|
||||||
"packages/node_modules/@node-red/editor-client/src/vendor/i18next/i18next.min.js",
|
"node_modules/i18next/i18next.min.js",
|
||||||
|
"node_modules/i18next-http-backend/i18nextHttpBackend.min.js",
|
||||||
|
"node_modules/jquery-i18next/jquery-i18next.min.js",
|
||||||
"node_modules/jsonata/jsonata-es5.min.js",
|
"node_modules/jsonata/jsonata-es5.min.js",
|
||||||
"packages/node_modules/@node-red/editor-client/src/vendor/jsonata/formatter.js",
|
"packages/node_modules/@node-red/editor-client/src/vendor/jsonata/formatter.js",
|
||||||
"packages/node_modules/@node-red/editor-client/src/vendor/ace/ace.js",
|
"packages/node_modules/@node-red/editor-client/src/vendor/ace/ace.js",
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
"fs.notify": "0.0.4",
|
"fs.notify": "0.0.4",
|
||||||
"hash-sum": "2.0.0",
|
"hash-sum": "2.0.0",
|
||||||
"https-proxy-agent": "5.0.0",
|
"https-proxy-agent": "5.0.0",
|
||||||
"i18next": "15.1.2",
|
"i18next": "20.2.1",
|
||||||
"iconv-lite": "0.6.2",
|
"iconv-lite": "0.6.2",
|
||||||
"is-utf8": "0.2.1",
|
"is-utf8": "0.2.1",
|
||||||
"js-yaml": "3.14.0",
|
"js-yaml": "3.14.0",
|
||||||
@ -102,6 +102,8 @@
|
|||||||
"grunt-simple-mocha": "~0.4.1",
|
"grunt-simple-mocha": "~0.4.1",
|
||||||
"grunt-simple-nyc": "^3.0.1",
|
"grunt-simple-nyc": "^3.0.1",
|
||||||
"http-proxy": "1.18.1",
|
"http-proxy": "1.18.1",
|
||||||
|
"i18next-http-backend": "1.2.1",
|
||||||
|
"jquery-i18next": "1.2.1",
|
||||||
"jsdoc-nr-template": "github:node-red/jsdoc-nr-template",
|
"jsdoc-nr-template": "github:node-red/jsdoc-nr-template",
|
||||||
"marked": "2.0.1",
|
"marked": "2.0.1",
|
||||||
"minami": "1.2.3",
|
"minami": "1.2.3",
|
||||||
|
@ -18,53 +18,66 @@ RED.i18n = (function() {
|
|||||||
|
|
||||||
var apiRootUrl;
|
var apiRootUrl;
|
||||||
|
|
||||||
|
function detectLanguage() {
|
||||||
|
return navigator.language
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
init: function(options, done) {
|
init: function(options, done) {
|
||||||
apiRootUrl = options.apiRootUrl||"";
|
apiRootUrl = options.apiRootUrl||"";
|
||||||
var preferredLanguage = localStorage.getItem("editor-language");
|
var preferredLanguage = localStorage.getItem("editor-language");
|
||||||
var opts = {
|
var opts = {
|
||||||
resGetPath: apiRootUrl+'locales/__ns__?lng=__lng__',
|
backend: {
|
||||||
dynamicLoad: false,
|
loadPath: apiRootUrl+'locales/__ns__?lng=__lng__',
|
||||||
load:'current',
|
|
||||||
ns: {
|
|
||||||
namespaces: ["editor","node-red","jsonata","infotips"],
|
|
||||||
defaultNs: "editor"
|
|
||||||
},
|
},
|
||||||
|
lng: 'en-US',
|
||||||
|
// debug: true,
|
||||||
|
preload:['en-US'],
|
||||||
|
ns: ["editor","node-red","jsonata","infotips"],
|
||||||
|
defaultNS: "editor",
|
||||||
fallbackLng: ['en-US'],
|
fallbackLng: ['en-US'],
|
||||||
useCookie: false,
|
returnObjects: true,
|
||||||
returnObjectTrees: true
|
interpolation: {
|
||||||
|
unescapeSuffix: 'HTML',
|
||||||
|
escapeValue: false,
|
||||||
|
prefix: '__',
|
||||||
|
suffix: '__'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if (preferredLanguage) {
|
if (preferredLanguage) {
|
||||||
opts.lng = preferredLanguage;
|
opts.lng = preferredLanguage;
|
||||||
}
|
}
|
||||||
i18n.init(opts,function() {
|
|
||||||
|
i18next.use(i18nextHttpBackend).init(opts,function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
jqueryI18next.init(i18next, $, { handleName: 'i18n' });
|
||||||
|
|
||||||
|
|
||||||
RED["_"] = function() {
|
RED["_"] = function() {
|
||||||
var v = i18n.t.apply(null,arguments);
|
var v = i18next.t.apply(i18next,arguments);
|
||||||
if (typeof v === 'string') {
|
if (typeof v === 'string') {
|
||||||
return v;
|
return v;
|
||||||
} else {
|
} else {
|
||||||
return arguments[0];
|
return arguments[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
lang: function() {
|
lang: function() {
|
||||||
// Gets the active message catalog language. This is based on what
|
// Gets the active message catalog language. This is based on what
|
||||||
// locale the editor is using and what languages are available.
|
// locale the editor is using and what languages are available.
|
||||||
//
|
//
|
||||||
var preferredLangs = i18n.functions.toLanguages(localStorage.getItem("editor-language")||i18n.detectLanguage());
|
var preferredLangs = [localStorage.getItem("editor-language")|| detectLanguage()].concat(i18next.languages);
|
||||||
var knownLangs = RED.settings.theme("languages")||["en-US"];
|
var knownLangs = RED.settings.theme("languages")||["en-US"];
|
||||||
for (var i=0;i<preferredLangs.length;i++) {
|
for (var i=0;i<preferredLangs.length;i++) {
|
||||||
if (knownLangs.indexOf(preferredLangs[i]) > -1) {
|
if (knownLangs.indexOf(preferredLangs[i]) > -1) {
|
||||||
return preferredLangs[i]
|
return preferredLangs[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 'end-US'
|
return 'en-US'
|
||||||
},
|
},
|
||||||
loadNodeCatalog: function(namespace,done) {
|
loadNodeCatalog: function(namespace,done) {
|
||||||
var languageList = i18n.functions.toLanguages(localStorage.getItem("editor-language")||i18n.detectLanguage());
|
var languageList = [localStorage.getItem("editor-language")|| detectLanguage()].concat(i18next.languages);
|
||||||
var toLoad = languageList.length;
|
var toLoad = languageList.length;
|
||||||
languageList.forEach(function(lang) {
|
languageList.forEach(function(lang) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -74,7 +87,7 @@ RED.i18n = (function() {
|
|||||||
cache: false,
|
cache: false,
|
||||||
url: apiRootUrl+'nodes/'+namespace+'/messages?lng='+lang,
|
url: apiRootUrl+'nodes/'+namespace+'/messages?lng='+lang,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
i18n.addResourceBundle(lang,namespace,data);
|
i18next.addResourceBundle(lang,namespace,data);
|
||||||
toLoad--;
|
toLoad--;
|
||||||
if (toLoad === 0) {
|
if (toLoad === 0) {
|
||||||
done();
|
done();
|
||||||
@ -86,7 +99,7 @@ RED.i18n = (function() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
loadNodeCatalogs: function(done) {
|
loadNodeCatalogs: function(done) {
|
||||||
var languageList = i18n.functions.toLanguages(localStorage.getItem("editor-language")||i18n.detectLanguage());
|
var languageList = [localStorage.getItem("editor-language")|| detectLanguage()].concat(i18next.languages);
|
||||||
var toLoad = languageList.length;
|
var toLoad = languageList.length;
|
||||||
|
|
||||||
languageList.forEach(function(lang) {
|
languageList.forEach(function(lang) {
|
||||||
@ -99,7 +112,7 @@ RED.i18n = (function() {
|
|||||||
success: function(data) {
|
success: function(data) {
|
||||||
var namespaces = Object.keys(data);
|
var namespaces = Object.keys(data);
|
||||||
namespaces.forEach(function(ns) {
|
namespaces.forEach(function(ns) {
|
||||||
i18n.addResourceBundle(lang,ns,data[ns]);
|
i18next.addResourceBundle(lang,ns,data[ns]);
|
||||||
});
|
});
|
||||||
toLoad--;
|
toLoad--;
|
||||||
if (toLoad === 0) {
|
if (toLoad === 0) {
|
||||||
@ -111,7 +124,7 @@ RED.i18n = (function() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
loadPluginCatalogs: function(done) {
|
loadPluginCatalogs: function(done) {
|
||||||
var languageList = i18n.functions.toLanguages(localStorage.getItem("editor-language")||i18n.detectLanguage());
|
var languageList = [localStorage.getItem("editor-language")|| detectLanguage()].concat(i18next.languages);
|
||||||
var toLoad = languageList.length;
|
var toLoad = languageList.length;
|
||||||
|
|
||||||
languageList.forEach(function(lang) {
|
languageList.forEach(function(lang) {
|
||||||
@ -124,7 +137,7 @@ RED.i18n = (function() {
|
|||||||
success: function(data) {
|
success: function(data) {
|
||||||
var namespaces = Object.keys(data);
|
var namespaces = Object.keys(data);
|
||||||
namespaces.forEach(function(ns) {
|
namespaces.forEach(function(ns) {
|
||||||
i18n.addResourceBundle(lang,ns,data[ns]);
|
i18next.addResourceBundle(lang,ns,data[ns]);
|
||||||
});
|
});
|
||||||
toLoad--;
|
toLoad--;
|
||||||
if (toLoad === 0) {
|
if (toLoad === 0) {
|
||||||
@ -133,6 +146,7 @@ RED.i18n = (function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
|
detectLanguage: detectLanguage
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
@ -36,7 +36,7 @@ var RED = (function() {
|
|||||||
}
|
}
|
||||||
function loadPlugins(done) {
|
function loadPlugins(done) {
|
||||||
loader.reportProgress(RED._("event.loadPlugins",{count:""}), 17)
|
loader.reportProgress(RED._("event.loadPlugins",{count:""}), 17)
|
||||||
var lang = localStorage.getItem("editor-language")||i18n.detectLanguage();
|
var lang = localStorage.getItem("editor-language")||RED.i18n.detectLanguage();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
headers: {
|
headers: {
|
||||||
@ -176,7 +176,7 @@ var RED = (function() {
|
|||||||
|
|
||||||
function loadNodes() {
|
function loadNodes() {
|
||||||
loader.reportProgress(RED._("event.loadNodes",{count:""}), 30)
|
loader.reportProgress(RED._("event.loadNodes",{count:""}), 30)
|
||||||
var lang = localStorage.getItem("editor-language")||i18n.detectLanguage();
|
var lang = localStorage.getItem("editor-language")||RED.i18n.detectLanguage();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
headers: {
|
headers: {
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user