From 2f884ec77818a0f60e2a18cdd3f5782e02f3d73a Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Tue, 11 Dec 2018 22:33:11 +0900 Subject: [PATCH] i18 support for markdown editor tooltip --- .../editor-client/locales/en-US/editor.json | 14 ++++++++- .../editor-client/locales/ja/editor.json | 14 ++++++++- .../src/js/ui/editors/markdown.js | 29 +++++++++---------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json index 769fcaa44..65e89e6fb 100644 --- a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json +++ b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json @@ -718,7 +718,19 @@ }, "markdownEditor": { "title": "Markdown editor", - "format": "Formatted with markdown" + "format": "Formatted with markdown", + "heading1": "Heading 1", + "heading2": "Heading 2", + "heading3": "Heading 3", + "bold": "Bold", + "italic": "Italic", + "code": "Code", + "ordered-list": "Ordered list", + "unordered-list": "Unordered list", + "quote": "Quote", + "link": "Link", + "horizontal-rule": "Horizontal rule", + "toggle-preview": "Toggle preview" }, "bufferEditor": { "title": "Buffer editor", diff --git a/packages/node_modules/@node-red/editor-client/locales/ja/editor.json b/packages/node_modules/@node-red/editor-client/locales/ja/editor.json index bf5e98520..0ab8c8409 100644 --- a/packages/node_modules/@node-red/editor-client/locales/ja/editor.json +++ b/packages/node_modules/@node-red/editor-client/locales/ja/editor.json @@ -715,7 +715,19 @@ "format": "JSONフォーマット" }, "markdownEditor": { - "title": "マークダウンエディタ" + "title": "マークダウンエディタ", + "heading1": "見出しレベル1", + "heading2": "見出しレベル2", + "heading3": "見出しレベル3", + "bold": "太字", + "italic": "斜体", + "code": "コード", + "ordered-list": "箇条書き(番号付き)", + "unordered-list": "箇条書き", + "quote": "引用", + "link": "リンク", + "horizontal-rule": "区切り線", + "toggle-preview": "プレビュー表示切替え" }, "bufferEditor": { "title": "バッファエディタ", diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/editors/markdown.js b/packages/node_modules/@node-red/editor-client/src/js/ui/editors/markdown.js index 89d09397a..4541597f4 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/editors/markdown.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/editors/markdown.js @@ -51,20 +51,6 @@ var panels; - var styleActions = { - 'h1': { newline: true, before:"# ", tooltip:"Heading 1"}, - 'h2': { newline: true, before:"## ", tooltip:"Heading 2"}, - 'h3': { newline: true, before:"### ", tooltip:"Heading 3"}, - 'b': { before:"**", after: "**", tooltip: "Bold" }, - 'i': { before:"_", after: "_", tooltip: "Italic" }, - 'code': { before:"`", after: "`", tooltip: "Code" }, - 'ol': { before:" * ", newline: true, tooltip: "Ordered list" }, - 'ul': { before:" - ", newline: true, tooltip: "Unordered list" }, - 'bq': { before:"> ", newline: true, tooltip: "Quote" }, - 'link': { before:"[", after: "]()", tooltip: "Link"}, - 'hr': { before:"\n---\n\n", tooltip: "Horizontal rule" } - } - var definition = { show: function(options) { var value = options.value; @@ -150,7 +136,7 @@ panels.ratio(0.5); } }); - RED.popover.tooltip($("#node-btn-markdown-preview"),"Toggle preview"); + RED.popover.tooltip($("#node-btn-markdown-preview"), RED._("markdownEditor.toggle-preview")); if (options.cursor) { expressionEditor.gotoLine(options.cursor.row+1,options.cursor.column,false); @@ -170,6 +156,19 @@ }, buildToolbar: function(container, editor) { + var styleActions = { + 'h1': { newline: true, before:"# ", tooltip:RED._("markdownEditor.heading1")}, + 'h2': { newline: true, before:"## ", tooltip:RED._("markdownEditor.heading2")}, + 'h3': { newline: true, before:"### ", tooltip:RED._("markdownEditor.heading3")}, + 'b': { before:"**", after: "**", tooltip: RED._("markdownEditor.bold")}, + 'i': { before:"_", after: "_", tooltip: RED._("markdownEditor.italic")}, + 'code': { before:"`", after: "`", tooltip: RED._("markdownEditor.code")}, + 'ol': { before:" * ", newline: true, tooltip: RED._("markdownEditor.ordered-list")}, + 'ul': { before:" - ", newline: true, tooltip: RED._("markdownEditor.unordered-list")}, + 'bq': { before:"> ", newline: true, tooltip: RED._("markdownEditor.quote")}, + 'link': { before:"[", after: "]()", tooltip: RED._("markdownEditor.link")}, + 'hr': { before:"\n---\n\n", tooltip: RED._("markdownEditor.horizontal-rule")} + } var toolbar = $(toolbarTemplate).appendTo(container); toolbar.find('button[data-style]').each(function(el) { var style = styleActions[$(this).data('style')];