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

@ -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);
});

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.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);

View File

@ -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() {