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

View File

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