add i18n support for port label of inject/exec/httprequest/file node

This commit is contained in:
Hiroyasu Nishiyama
2019-02-28 20:22:33 +09:00
parent fec52a8151
commit ae726c199b
6 changed files with 81 additions and 19 deletions

View File

@@ -172,17 +172,23 @@
inputs:0,
outputs:1,
outputLabels: function(index) {
var labels = { str:"string", num:"number", bool:"boolean", json:"object", flow:"flow context", global:"global context" };
var lab = labels[this.payloadType] || this.payloadType;
if (lab === "object") {
var lab = this.payloadType;
if (lab === "json") {
try {
lab = typeof JSON.parse(this.payload);
if (lab === "object") {
if (Array.isArray(JSON.parse(this.payload))) { lab = "Array"; }
}
} catch(e) { lab = "Invalid JSON Object"; }
} catch(e) {
return this._("inject.label.invalid"); }
}
return lab; },
var name = "inject.label."+lab;
var label = this._(name);
if (name !== label) {
return label;
}
return lab;
},
label: function() {
var suffix = "";
// if fire once then add small indication

View File

@@ -66,7 +66,13 @@
},
inputs:1,
outputs:3,
outputLabels: ["stdout","stderr","return code"],
outputLabels: function(i) {
return [
this._("exec.label.stdout"),
this._("exec.label.stderr"),
this._("exec.label.retcode")
][i];
},
icon: "arrow-in.png",
align: "right",
label: function() {

View File

@@ -102,7 +102,11 @@
inputs:1,
outputs:1,
outputLabels: function(i) {
return ({txt:"UTF8 string", bin:"binary buffer", obj:"parsed JSON object"}[this.ret]);
return ({
txt: this._("httpin.label.utf8String"),
bin: this._("httpin.label.binaryBuffer"),
obj: this._("httpin.label.jsonObject")
}[this.ret]);
},
icon: "white-globe.png",
label: function() {

View File

@@ -100,7 +100,7 @@
inputs:1,
outputs:1,
outputLabels: function(i) {
return (this.format === "utf8") ? "UTF8 string" : "binary buffer";
return (this._((this.format === "utf8") ? "file.label.utf8String" : "file.label.binaryBuffer"));
},
icon: "file-in.png",
label: function() {