Added i18n and legacy output label support

This commit is contained in:
Paul Wieland 2020-04-27 12:16:20 -04:00
parent 3e898c487a
commit 25aadc690a
2 changed files with 18 additions and 10 deletions

View File

@ -183,23 +183,30 @@
if (payloadProperty && topicProperty) {
lab = payloadProperty.vt;
} else if (propertyCount > 1){
lab = propertyCount + ' properties';
lab = propertyCount + " " + this._("inject.label.properties");
} else if(propertyCount === 1){
lab = this.props[0].vt;
}
// Friendly names
switch(lab){
case 'date': lab = 'timestamp'; break;
case 'str': lab = 'string'; break;
case 'num': lab = 'number'; break;
case 'bin': lab = 'buffer'; break;
case '': lab = 'nothing'; break;
} else {
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) {
return this._("inject.label.invalid");
}
}
}else{
lab = 'legacy payload';
}
var name = "inject.label."+lab;
var label = this._(name);
if (name !== label) { lab = label; }
return lab;
},
label: function() {

View File

@ -37,6 +37,7 @@
"stopped": "stopped",
"failed": "Inject failed: __error__",
"label": {
"properties": "Properties",
"repeat": "Repeat",
"flow": "flow context",
"global": "global context",