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:
parent
f0b4cb608a
commit
9bbd6a70b8
@ -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;
|
||||
|
@ -624,16 +624,8 @@ RED.editor = (function() {
|
||||
if (node_def.defaults[d].value) {
|
||||
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());
|
||||
|
Loading…
Reference in New Issue
Block a user