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

Add namespaced i18n function to node definition

This commit is contained in:
Nick O'Leary 2015-06-08 11:37:36 +01:00
parent f0b4cb608a
commit 9bbd6a70b8
2 changed files with 18 additions and 23 deletions

View File

@ -109,6 +109,21 @@ RED.nodes = (function() {
if (def.category != "subflows") {
def.set = nodeSets[typeToId[nt]];
nodeSets[typeToId[nt]].added = true;
var ns;
if (def.set.module === "node-red") {
ns = "node-red";
} else {
ns = def.set.id;
}
def["_"] = function() {
var args = Array.prototype.slice.call(arguments, 0);
if (args[0].indexOf(":") === -1) {
args[0] = ns+":"+args[0];
}
return RED._.apply(null,args);
}
// TODO: too tightly coupled into palette UI
}
RED.palette.add(nt,def);
@ -135,20 +150,8 @@ RED.nodes = (function() {
}
function addNode(n) {
var ns;
if (n.type.indexOf("subflow") !== 0) {
if (n._def.set.module === "node-red") {
ns = "node-red";
} else {
ns = n._def.set.id;
}
n["_"] = function() {
var args = Array.prototype.slice.call(arguments, 0);
if (args[0].indexOf(":") === -1) {
args[0] = ns+":"+args[0];
}
return RED._.apply(null,args);
}
n["_"] = n._def._;
}
if (n._def.category == "config") {
configNodes[n.id] = n;

View File

@ -625,15 +625,7 @@ RED.editor = (function() {
configNode[d] = node_def.defaults[d].value;
}
}
configNode["_"] = function() {
var args = Array.prototype.slice.call(arguments, 0);
if (args[0].indexOf(":") === -1) {
args[0] = ns+":"+args[0];
}
return RED._.apply(null,args);
}
configNode["_"] = node_def._;
}
$("#dialog-config-form").html($("script[data-template-name='"+type+"']").html());