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

Update locales module to new structure

This commit is contained in:
Nick O'Leary 2018-04-19 20:46:01 +01:00
parent 1cdb039ea2
commit 825b0fb22f
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 20 additions and 16 deletions

View File

@ -83,7 +83,7 @@ module.exports = {
// Locales // Locales
var locales = require("./locales"); var locales = require("./locales");
locales.init(runtime); locales.init(runtimeAPI);
editorApp.get('/locales/nodes',locales.getAllNodes,apiUtil.errorHandler); editorApp.get('/locales/nodes',locales.getAllNodes,apiUtil.errorHandler);
editorApp.get(/locales\/(.+)\/?$/,locales.get,apiUtil.errorHandler); editorApp.get(/locales\/(.+)\/?$/,locales.get,apiUtil.errorHandler);
@ -124,6 +124,5 @@ module.exports = {
}); });
}, },
stop: comms.stop, stop: comms.stop,
publish: comms.publish, publish: comms.publish
registerLibrary: library.register
} }

View File

@ -16,13 +16,14 @@
var fs = require('fs'); var fs = require('fs');
var path = require('path'); var path = require('path');
//var apiUtil = require('../util'); //var apiUtil = require('../util');
var i18n;
var redNodes; var i18n = require("../../util").i18n; // TODO: separate module
var runtimeAPI;
module.exports = { module.exports = {
init: function(runtime) { init: function(_runtimeAPI) {
i18n = runtime.i18n; runtimeAPI = _runtimeAPI;
redNodes = runtime.nodes;
}, },
get: function(req,res) { get: function(req,res) {
var namespace = req.params[0]; var namespace = req.params[0];
@ -40,13 +41,17 @@ module.exports = {
}, },
getAllNodes: function(req,res) { getAllNodes: function(req,res) {
var lngs = req.query.lng; var lngs = req.query.lng;
var nodeList = redNodes.getNodeList(); var opts = {
var result = {}; user: req.user
nodeList.forEach(function(n) { }
if (n.module !== "node-red") { runtimeAPI.nodes.getNodeList(opts).then(function(nodeList) {
result[n.id] = i18n.catalog(n.id,lngs)||{}; var result = {};
} nodeList.forEach(function(n) {
}); if (n.module !== "node-red") {
res.json(result); result[n.id] = i18n.catalog(n.id,lngs)||{};
}
});
res.json(result);
})
} }
} }