1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Load base locales in editor

This commit is contained in:
Nick O'Leary 2015-04-26 23:02:14 +01:00
parent b2caba593f
commit 0705589cc2
5 changed files with 28 additions and 6 deletions

View File

@ -135,6 +135,21 @@ var RED = (function() {
RED.view.status(statusEnabled); RED.view.status(statusEnabled);
} }
function loadLocales() {
i18n.init({
ns: {
namespaces: ["editor"],
defaultNs: "editor"
},
fallbackLng: ['en-US']
},function() {
RED["_"] = function() {
return i18n.t.apply(null,arguments);
}
loadEditor();
});
}
function loadEditor() { function loadEditor() {
RED.menu.init({id:"btn-sidemenu", RED.menu.init({id:"btn-sidemenu",
options: [ options: [
@ -201,7 +216,7 @@ var RED = (function() {
ace.require("ace/ext/language_tools"); ace.require("ace/ext/language_tools");
RED.settings.init(loadEditor); RED.settings.init(loadLocales);
}); });

View File

@ -0,0 +1,3 @@
{
"foo": "fred"
}

View File

@ -86,7 +86,7 @@ function init(adminApp,storage) {
adminApp.get("/nodes/:mod/:set",needsPermission("nodes.read"),nodes.getSet); adminApp.get("/nodes/:mod/:set",needsPermission("nodes.read"),nodes.getSet);
adminApp.put("/nodes/:mod/:set",needsPermission("nodes.write"),nodes.putSet); adminApp.put("/nodes/:mod/:set",needsPermission("nodes.write"),nodes.putSet);
adminApp.get(/^\/locales\/(.+?)\/(.*)$/,needsPermission("nodes.read"),locales.get); adminApp.get(/^\/locales\/(.+?)\/(.*).json$/,needsPermission("nodes.read"),locales.get);
// Library // Library
library.init(adminApp); library.init(adminApp);

View File

@ -22,9 +22,13 @@ var fs = require("fs");
var defaultLang = "en-US"; var defaultLang = "en-US";
var resourceMap = { var resourceMap = {
"messages": { "runtime": {
basedir: path.resolve(__dirname+"/../locales"), basedir: path.resolve(__dirname+"/../locales"),
file:"messages.json" file:"runtime.json"
},
"editor": {
basedir: path.resolve(__dirname+"/../locales"),
file: "editor.json"
} }
} }
var resourceCache = {} var resourceCache = {}
@ -69,8 +73,8 @@ function init() {
i18n.backend(MessageFileLoader); i18n.backend(MessageFileLoader);
i18n.init({ i18n.init({
ns: { ns: {
namespaces: ["messages"], namespaces: ["runtime","editor"],
defaultNs: "messages" defaultNs: "runtime"
}, },
fallbackLng: ['en-US'] fallbackLng: ['en-US']
},function() { },function() {