mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Added i18n and legacy output label support
This commit is contained in:
parent
3e898c487a
commit
25aadc690a
@ -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() {
|
||||
|
@ -37,6 +37,7 @@
|
||||
"stopped": "stopped",
|
||||
"failed": "Inject failed: __error__",
|
||||
"label": {
|
||||
"properties": "Properties",
|
||||
"repeat": "Repeat",
|
||||
"flow": "flow context",
|
||||
"global": "global context",
|
||||
|
Loading…
Reference in New Issue
Block a user