Skip to content

Commit 0705589

Browse files
committed
Load base locales in editor
1 parent b2caba5 commit 0705589

5 files changed

Lines changed: 28 additions & 6 deletions

File tree

editor/js/main.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@ var RED = (function() {
134134
statusEnabled = state;
135135
RED.view.status(statusEnabled);
136136
}
137+
138+
function loadLocales() {
139+
i18n.init({
140+
ns: {
141+
namespaces: ["editor"],
142+
defaultNs: "editor"
143+
},
144+
fallbackLng: ['en-US']
145+
},function() {
146+
RED["_"] = function() {
147+
return i18n.t.apply(null,arguments);
148+
}
149+
loadEditor();
150+
});
151+
}
137152

138153
function loadEditor() {
139154
RED.menu.init({id:"btn-sidemenu",
@@ -201,7 +216,7 @@ var RED = (function() {
201216

202217
ace.require("ace/ext/language_tools");
203218

204-
RED.settings.init(loadEditor);
219+
RED.settings.init(loadLocales);
205220
});
206221

207222

locales/en-US/editor.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"foo": "fred"
3+
}

red/api/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function init(adminApp,storage) {
8686
adminApp.get("/nodes/:mod/:set",needsPermission("nodes.read"),nodes.getSet);
8787
adminApp.put("/nodes/:mod/:set",needsPermission("nodes.write"),nodes.putSet);
8888

89-
adminApp.get(/^\/locales\/(.+?)\/(.*)$/,needsPermission("nodes.read"),locales.get);
89+
adminApp.get(/^\/locales\/(.+?)\/(.*).json$/,needsPermission("nodes.read"),locales.get);
9090

9191
// Library
9292
library.init(adminApp);

red/i18n.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ var fs = require("fs");
2222
var defaultLang = "en-US";
2323

2424
var resourceMap = {
25-
"messages": {
25+
"runtime": {
2626
basedir: path.resolve(__dirname+"/../locales"),
27-
file:"messages.json"
27+
file:"runtime.json"
28+
},
29+
"editor": {
30+
basedir: path.resolve(__dirname+"/../locales"),
31+
file: "editor.json"
2832
}
2933
}
3034
var resourceCache = {}
@@ -69,8 +73,8 @@ function init() {
6973
i18n.backend(MessageFileLoader);
7074
i18n.init({
7175
ns: {
72-
namespaces: ["messages"],
73-
defaultNs: "messages"
76+
namespaces: ["runtime","editor"],
77+
defaultNs: "runtime"
7478
},
7579
fallbackLng: ['en-US']
7680
},function() {

0 commit comments

Comments
 (0)