diff --git a/editor/js/main.js b/editor/js/main.js index 8d9ccb492..4a184ae5f 100644 --- a/editor/js/main.js +++ b/editor/js/main.js @@ -134,6 +134,21 @@ var RED = (function() { statusEnabled = state; 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() { RED.menu.init({id:"btn-sidemenu", @@ -201,7 +216,7 @@ var RED = (function() { ace.require("ace/ext/language_tools"); - RED.settings.init(loadEditor); + RED.settings.init(loadLocales); }); diff --git a/locales/en-US/editor.json b/locales/en-US/editor.json new file mode 100644 index 000000000..544b26520 --- /dev/null +++ b/locales/en-US/editor.json @@ -0,0 +1,3 @@ +{ + "foo": "fred" +} diff --git a/locales/en-US/messages.json b/locales/en-US/runtime.json similarity index 100% rename from locales/en-US/messages.json rename to locales/en-US/runtime.json diff --git a/red/api/index.js b/red/api/index.js index e9e51bdf5..00f087ca6 100644 --- a/red/api/index.js +++ b/red/api/index.js @@ -86,7 +86,7 @@ function init(adminApp,storage) { adminApp.get("/nodes/:mod/:set",needsPermission("nodes.read"),nodes.getSet); 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.init(adminApp); diff --git a/red/i18n.js b/red/i18n.js index e4a7018a4..06e955e4d 100644 --- a/red/i18n.js +++ b/red/i18n.js @@ -22,9 +22,13 @@ var fs = require("fs"); var defaultLang = "en-US"; var resourceMap = { - "messages": { + "runtime": { basedir: path.resolve(__dirname+"/../locales"), - file:"messages.json" + file:"runtime.json" + }, + "editor": { + basedir: path.resolve(__dirname+"/../locales"), + file: "editor.json" } } var resourceCache = {} @@ -69,8 +73,8 @@ function init() { i18n.backend(MessageFileLoader); i18n.init({ ns: { - namespaces: ["messages"], - defaultNs: "messages" + namespaces: ["runtime","editor"], + defaultNs: "runtime" }, fallbackLng: ['en-US'] },function() {