mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Register node message catalog directly, not via event
This commit is contained in:
parent
1dd9984521
commit
043b8a3105
@ -26,18 +26,10 @@ var RED;
|
||||
var settings;
|
||||
var runtime;
|
||||
|
||||
function registerMessageCatalog(info) {
|
||||
runtime.i18n.registerMessageCatalog(info.namespace,info.dir,info.file);
|
||||
}
|
||||
|
||||
function init(_runtime) {
|
||||
runtime = _runtime;
|
||||
settings = runtime.settings;
|
||||
localfilesystem.init(runtime);
|
||||
if (runtime.events) {
|
||||
runtime.events.removeListener("node-locales-dir", registerMessageCatalog);
|
||||
runtime.events.on("node-locales-dir", registerMessageCatalog);
|
||||
}
|
||||
RED = require('../../../red');
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ var path = require("path");
|
||||
|
||||
var events;
|
||||
var log;
|
||||
var i18n;
|
||||
|
||||
var settings;
|
||||
var defaultNodesDir = path.resolve(path.join(__dirname,"..","..","..","..","nodes"));
|
||||
@ -29,6 +30,7 @@ function init(runtime,_defaultNodesDir,_disableNodePathScan) {
|
||||
settings = runtime.settings;
|
||||
events = runtime.events;
|
||||
log = runtime.log;
|
||||
i18n = runtime.i18n;
|
||||
|
||||
if (_disableNodePathScan) {
|
||||
disableNodePathScan = _disableNodePathScan;
|
||||
@ -204,11 +206,7 @@ function getNodeFiles(_defaultNodesDir,disableNodePathScan) {
|
||||
//console.log(nodeFiles);
|
||||
|
||||
var defaultLocalesPath = path.resolve(path.join(defaultNodesDir,"core","locales"));
|
||||
events.emit("node-locales-dir", {
|
||||
namespace:"node-red",
|
||||
dir: defaultLocalesPath,
|
||||
file: "messages.json"
|
||||
});
|
||||
i18n.registerMessageCatalog("node-red",defaultLocalesPath,"messages.json");
|
||||
|
||||
if (settings.userDir) {
|
||||
dir = path.join(settings.userDir,"nodes");
|
||||
|
@ -45,7 +45,7 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
}
|
||||
describe("#getNodeFiles",function() {
|
||||
it("Finds all the node files in the resources tree",function(done) {
|
||||
localfilesystem.init({events:{emit:function(){}},settings:{}});
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{}});
|
||||
var nodeList = localfilesystem.getNodeFiles(resourcesDir,true);
|
||||
nodeList.should.have.a.property("node-red");
|
||||
var nm = nodeList['node-red'];
|
||||
@ -56,7 +56,7 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
done();
|
||||
});
|
||||
it("Excludes node files from settings",function(done) {
|
||||
localfilesystem.init({events:{emit:function(){}},settings:{nodesExcludes:['TestNode1.js']}});
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{nodesExcludes:['TestNode1.js']}});
|
||||
var nodeList = localfilesystem.getNodeFiles(resourcesDir,true);
|
||||
nodeList.should.have.a.property("node-red");
|
||||
var nm = nodeList['node-red'];
|
||||
@ -66,7 +66,7 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
done();
|
||||
});
|
||||
it("Finds nodes in userDir/nodes",function(done) {
|
||||
localfilesystem.init({events:{emit:function(){}},settings:{userDir:userDir}});
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{userDir:userDir}});
|
||||
var nodeList = localfilesystem.getNodeFiles(__dirname,true);
|
||||
nodeList.should.have.a.property("node-red");
|
||||
var nm = nodeList['node-red'];
|
||||
@ -77,7 +77,7 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
});
|
||||
|
||||
it("Finds nodes in settings.nodesDir (string)",function(done) {
|
||||
localfilesystem.init({events:{emit:function(){}},settings:{nodesDir:userDir}});
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{nodesDir:userDir}});
|
||||
var nodeList = localfilesystem.getNodeFiles(__dirname,true);
|
||||
nodeList.should.have.a.property("node-red");
|
||||
var nm = nodeList['node-red'];
|
||||
@ -87,7 +87,7 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
done();
|
||||
});
|
||||
it("Finds nodes in settings.nodesDir (array)",function(done) {
|
||||
localfilesystem.init({events:{emit:function(){}},settings:{nodesDir:[userDir]}});
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{nodesDir:[userDir]}});
|
||||
var nodeList = localfilesystem.getNodeFiles(__dirname,true);
|
||||
nodeList.should.have.a.property("node-red");
|
||||
var nm = nodeList['node-red'];
|
||||
@ -106,7 +106,7 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
}
|
||||
return _join.apply(null,arguments);
|
||||
}));
|
||||
localfilesystem.init({events:{emit:function(){}},settings:{}});
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{}});
|
||||
var nodeList = localfilesystem.getNodeFiles(moduleDir,false);
|
||||
nodeList.should.have.a.property("node-red");
|
||||
var nm = nodeList['node-red'];
|
||||
@ -141,7 +141,7 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
}
|
||||
return _join.apply(null,arguments);
|
||||
}));
|
||||
localfilesystem.init({events:{emit:function(){}},settings:{}},moduleDir,true);
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{}},moduleDir,true);
|
||||
var nodeModule = localfilesystem.getModuleFiles('TestNodeModule');
|
||||
nodeModule.should.have.a.property('TestNodeModule');
|
||||
nodeModule['TestNodeModule'].should.have.a.property('name','TestNodeModule');
|
||||
@ -165,7 +165,7 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
}
|
||||
return _join.apply(null,arguments);
|
||||
}));
|
||||
localfilesystem.init({events:{emit:function(){}},settings:{}},moduleDir,true);
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{}},moduleDir,true);
|
||||
/*jshint immed: false */
|
||||
(function(){
|
||||
localfilesystem.getModuleFiles('WontExistModule');
|
||||
|
Loading…
Reference in New Issue
Block a user