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

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, inputs:0,
outputs:1, outputs:1,
outputLabels: function(index) { outputLabels: function(index) {
var labels = { str:"string", num:"number", bool:"boolean", json:"object", flow:"flow context", global:"global context" }; var lab = this.payloadType;
var lab = labels[this.payloadType] || this.payloadType; if (lab === "json") {
if (lab === "object") {
try { try {
lab = typeof JSON.parse(this.payload); lab = typeof JSON.parse(this.payload);
if (lab === "object") { if (lab === "object") {
if (Array.isArray(JSON.parse(this.payload))) { lab = "Array"; } 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() { label: function() {
var suffix = ""; var suffix = "";
// if fire once then add small indication // if fire once then add small indication

View File

@ -66,7 +66,13 @@
}, },
inputs:1, inputs:1,
outputs:3, 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", icon: "arrow-in.png",
align: "right", align: "right",
label: function() { label: function() {

View File

@ -102,7 +102,11 @@
inputs:1, inputs:1,
outputs:1, outputs:1,
outputLabels: function(i) { 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", icon: "white-globe.png",
label: function() { label: function() {

View File

@ -100,7 +100,7 @@
inputs:1, inputs:1,
outputs:1, outputs:1,
outputLabels: function(i) { 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", icon: "file-in.png",
label: function() { label: function() {

View File

@ -35,7 +35,22 @@
"stopped": "stopped", "stopped": "stopped",
"failed": "Inject failed: __error__", "failed": "Inject failed: __error__",
"label": { "label": {
"repeat": "Repeat" "repeat": "Repeat",
"flow": "flow context",
"global": "global context",
"str": "string",
"num": "number",
"bool": "boolean",
"json": "object",
"bin": "buffer",
"date": "timestamp",
"env": "env variable",
"object": "object",
"string": "string",
"boolean": "boolean",
"number": "number",
"Array": "Array",
"invalid": "Invalid JSON Object"
}, },
"timestamp": "timestamp", "timestamp": "timestamp",
"none": "none", "none": "none",
@ -174,7 +189,10 @@
"timeout": "Timeout", "timeout": "Timeout",
"timeoutplace": "optional", "timeoutplace": "optional",
"return": "Output", "return": "Output",
"seconds": "seconds" "seconds": "seconds",
"stdout": "stdout",
"stderr": "stderr",
"retcode": "return code"
}, },
"placeholder": { "placeholder": {
"extraparams": "extra input parameters" "extraparams": "extra input parameters"
@ -380,7 +398,10 @@
"status": "Status code", "status": "Status code",
"headers": "Headers", "headers": "Headers",
"other": "other", "other": "other",
"paytoqs" : "Append msg.payload as query string parameters" "paytoqs" : "Append msg.payload as query string parameters",
"utf8String": "UTF8 string",
"binaryBuffer": "binary buffer",
"jsonObject": "parsed JSON object"
}, },
"setby": "- set by msg.method -", "setby": "- set by msg.method -",
"basicauth": "Use basic authentication", "basicauth": "Use basic authentication",
@ -833,7 +854,9 @@
"breaklines": "Break into lines", "breaklines": "Break into lines",
"filelabel": "file", "filelabel": "file",
"sendError": "Send message on error (legacy mode)", "sendError": "Send message on error (legacy mode)",
"deletelabel": "delete __file__" "deletelabel": "delete __file__",
"utf8String": "UTF8 string",
"binaryBuffer": "binary buffer"
}, },
"action": { "action": {
"append": "append to file", "append": "append to file",

View File

@ -35,9 +35,24 @@
"stopped": "stopped", "stopped": "stopped",
"failed": "inject失敗: __error__", "failed": "inject失敗: __error__",
"label": { "label": {
"repeat": "繰り返し" "repeat": "繰り返し",
"flow": "フローコンテクスト",
"global": "グローバルコンテクスト",
"str": "文字列",
"num": "数値",
"bool": "真偽値",
"json": "オブジェクト",
"bin": "バッファ",
"date": "タイムスタンプ",
"env": "環境変数",
"object": "オブジェクト",
"string": "文字列",
"boolean": "真偽値",
"number": "数値",
"Array": "配列",
"invalid": "不正なJSON"
}, },
"timestamp": "timestamp", "timestamp": "タイムスタンプ",
"none": "なし", "none": "なし",
"interval": "指定した時間間隔", "interval": "指定した時間間隔",
"interval-time": "指定した時間間隔、日時", "interval-time": "指定した時間間隔、日時",
@ -174,7 +189,10 @@
"timeout": "タイムアウト", "timeout": "タイムアウト",
"timeoutplace": "任意", "timeoutplace": "任意",
"return": "出力", "return": "出力",
"seconds": "秒" "seconds": "秒",
"stdout": "標準出力",
"stderr": "標準エラー出力",
"retcode": "返却コード"
}, },
"placeholder": { "placeholder": {
"extraparams": "追加引数" "extraparams": "追加引数"
@ -380,7 +398,10 @@
"status": "状態コード", "status": "状態コード",
"headers": "ヘッダ", "headers": "ヘッダ",
"other": "その他", "other": "その他",
"paytoqs" : "msg.payloadをクエリパラメータに追加" "paytoqs" : "msg.payloadをクエリパラメータに追加",
"utf8String": "UTF8文字列",
"binaryBuffer": "バイナリバッファ",
"jsonObject": "JSONオブジェクト"
}, },
"setby": "- msg.methodに定義 -", "setby": "- msg.methodに定義 -",
"basicauth": "ベーシック認証を使用", "basicauth": "ベーシック認証を使用",
@ -390,9 +411,9 @@
"proxy-config": "プロキシ設定", "proxy-config": "プロキシ設定",
"use-proxyauth": "プロキシ認証を使用", "use-proxyauth": "プロキシ認証を使用",
"noproxy-hosts": "例外ホスト", "noproxy-hosts": "例外ホスト",
"utf8": "文字列", "utf8": "UTF8文字列",
"binary": "バイナリバッファ", "binary": "バイナリバッファ",
"json": "JSON", "json": "JSONオブジェクト",
"tip": { "tip": {
"in": "URLは相対パスになります。", "in": "URLは相対パスになります。",
"res": "本ノードに送付するメッセージは、<i>http input</i>ノードを起点としてください。", "res": "本ノードに送付するメッセージは、<i>http input</i>ノードを起点としてください。",
@ -831,7 +852,9 @@
"breaklines": "行へ分割", "breaklines": "行へ分割",
"filelabel": "file", "filelabel": "file",
"sendError": "エラーメッセージを送信(互換モード)", "sendError": "エラーメッセージを送信(互換モード)",
"deletelabel": "delete __file__" "deletelabel": "delete __file__",
"utf8String": "UTF8文字列",
"binaryBuffer": "バイナリバッファ"
}, },
"action": { "action": {
"append": "ファイルへ追記", "append": "ファイルへ追記",