[ja] Support i18n 70-base64 node. (#591)

* [ja] Translate 70-base64 node.

* Fix PR review #591 "Buffer" -> "バッファ".

We have used Japanese katakana words of "buffer" in http-request and file-out nodes.

* Fix PR review #591 "Base64" -> "base64"

* Fix PR review #591 "Base64から文字列へデコード" -> "Base64から文字列へ変換"
This commit is contained in:
Ryoichi Obara 2019-10-29 02:40:41 +09:00 committed by Dave Conway-Jones
parent 0f46364a55
commit 739b3e595c
7 changed files with 73 additions and 19 deletions

View File

@ -1,11 +1,11 @@
<script type="text/x-red" data-template-name="base64">
<div class="form-row">
<label for="node-input-action"><i class="fa fa-dot-circle-o"></i> Action</label>
<label for="node-input-action"><i class="fa fa-dot-circle-o"></i> <span data-i18n="base64.label.action"></span></label>
<select style="width:70%" id="node-input-action">
<option value="">Convert Buffer <-> Base64</option>
<option value="str">Encode as Base64</option>
<option value="b64">Convert Base64 to String</option>
<option value="" data-i18n="base64.convert.buffer"></option>
<option value="str" data-i18n="base64.convert.encode"></option>
<option value="b64" data-i18n="base64.convert.decode"></option>
</select>
</div>
<div class="form-row">
@ -18,14 +18,6 @@
</div>
</script>
<script type="text/x-red" data-help-name="base64">
<p>A function that converts the chosen property (default <code>msg.payload</code>) to and from base64 format.</p>
<p>If the input is a buffer it converts it to a Base64 encoded string.</p>
<p>If the input is a Base64 string it converts it back to a binary buffer.</p>
<p>You can also fix coding into base64, and base64 to buffer if required.</p>
<p>Note: Using "Encode to Base64" will encode an already encoded string.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('base64',{
category: 'function',

View File

@ -24,9 +24,9 @@ module.exports = function(RED) {
RED.util.setMessageProperty(msg,node.property,value);
node.send(msg);
}
else { node.error("Invalid Base64 string",msg); }
else { node.error(RED._("base64.error.invalid"),msg); }
}
else { node.error("Not a Base64 string",msg); }
else { node.error(RED._("base64.error.nonbase64"),msg); }
}
else {
if (Buffer.isBuffer(value)) {
@ -46,18 +46,18 @@ module.exports = function(RED) {
node.send(msg);
}
else {
node.log("Not a Base64 string - maybe we should encode it...");
node.log(RED._("base64.log.nonbase64encode"));
value = Buffer.from(value).toString('base64');
RED.util.setMessageProperty(msg,node.property,value);
node.send(msg);
}
}
else {
node.warn("This node only handles strings or buffers.");
node.warn(RED._("base64.warn.cannothandle"));
}
}
}
else { node.warn("No property found to process"); }
else { node.warn(RED._("base64.warn.noproperty")); }
});
}
RED.nodes.registerType("base64",Base64Node);

View File

@ -0,0 +1,7 @@
<script type="text/x-red" data-help-name="base64">
<p>A function that converts the chosen property (default <code>msg.payload</code>) to and from base64 format.</p>
<p>If the input is a buffer it converts it to a Base64 encoded string.</p>
<p>If the input is a Base64 string it converts it back to a binary buffer.</p>
<p>You can also fix coding into base64, and base64 to buffer if required.</p>
<p>Note: Using "Encode to Base64" will encode an already encoded string.</p>
</script>

View File

@ -0,0 +1,24 @@
{
"base64": {
"base64": "base64",
"label": {
"action": "Action"
},
"convert": {
"buffer": "Convert Buffer <-> Base64",
"encode": "Encode as Base64",
"decode": "Convert Base64 to String"
},
"log": {
"nonbase64encode": "Not a Base64 string - maybe we should encode it..."
},
"warn": {
"cannothandle": "This node only handles strings or buffers.",
"noproperty": "No property found to process"
},
"error": {
"invalid": "Invalid Base64 string",
"nonbase64": "Not a Base64 string"
}
}
}

View File

@ -0,0 +1,7 @@
<script type="text/x-red" data-help-name="base64">
<p>選択したプロパティ(デフォルトは<code>msg.payload</code>)のBase64変換を行います。</p>
<p>入力がバッファであれば、Base64エンコードされた文字列に変換します。</p>
<p>入力がBase64文字列であれば、バイナリバッファ形式に変換します。</p>
<p>必要に応じて、入力をBase64であると固定して、Base64からバッファへの変換を行うこともできます。</p>
<p>補足: "Base64へエンコード"は、既にエンコードされた文字列もエンコードしてしまう可能性があります。</p>
</script>

View File

@ -0,0 +1,24 @@
{
"base64": {
"base64": "base64",
"label": {
"action": "動作"
},
"convert": {
"buffer": "バッファ <-> Base64の変換",
"encode": "Base64へエンコード",
"decode": "Base64から文字列へ変換"
},
"log": {
"nonbase64encode": "Base64文字列ではありませんが、変換します。"
},
"warn": {
"cannothandle": "このノードは文字列かバッファしか変換できません。",
"noproperty": "処理するためのプロパティが見つかりません。"
},
"error": {
"invalid": "不正なBase64文字列です。",
"nonbase64": "Base64文字列ではありません。"
}
}
}

View File

@ -250,7 +250,7 @@ describe('base64 node', function() {
return evt[0].type == "base64";
});
logEvents[0][0].should.have.a.property('msg');
logEvents[0][0].msg.toString().should.startWith("Invalid Base64 string");
logEvents[0][0].msg.toString().should.startWith("base64.error.invalid");
done();
} catch (e) {
done(e);
@ -275,7 +275,7 @@ describe('base64 node', function() {
return evt[0].type == "base64";
});
logEvents[0][0].should.have.a.property('msg');
logEvents[0][0].msg.toString().should.startWith("Not a Base64 string");
logEvents[0][0].msg.toString().should.startWith("base64.error.nonbase64");
done();
} catch (e) {
done(e);