From a5750d782e9b4f0060362459037086f4d2f18acf Mon Sep 17 00:00:00 2001 From: vrabe Date: Thu, 15 Oct 2020 20:26:22 +0800 Subject: [PATCH] fix(locale): remove hard coded strings (#4432) --- packages/netlify-cms-locales/src/en/index.js | 10 ++++++++++ .../netlify-cms-locales/src/zh_Hant/index.js | 10 ++++++++++ .../src/MarkdownControl/Toolbar.js | 18 +++++++++--------- .../src/MarkdownControl/VisualEditor.js | 10 ++++++++-- .../src/MarkdownControl/plugins/visual.js | 6 ++++-- 5 files changed, 41 insertions(+), 13 deletions(-) diff --git a/packages/netlify-cms-locales/src/en/index.js b/packages/netlify-cms-locales/src/en/index.js index 76d614c5..a6c7e021 100644 --- a/packages/netlify-cms-locales/src/en/index.js +++ b/packages/netlify-cms-locales/src/en/index.js @@ -136,6 +136,16 @@ const en = { }, editorWidgets: { markdown: { + bold: 'Bold', + italic: 'Italic', + code: 'Code', + link: 'Link', + linkPrompt: 'Enter the URL of the link', + headings: 'Headings', + quote: 'Quote', + bulletedList: 'Bulleted List', + numberedList: 'Numbered List', + addComponent: 'Add Component', richText: 'Rich Text', markdown: 'Markdown', }, diff --git a/packages/netlify-cms-locales/src/zh_Hant/index.js b/packages/netlify-cms-locales/src/zh_Hant/index.js index 6236acb7..8f6e4df8 100644 --- a/packages/netlify-cms-locales/src/zh_Hant/index.js +++ b/packages/netlify-cms-locales/src/zh_Hant/index.js @@ -134,6 +134,16 @@ const zh_Hant = { }, editorWidgets: { markdown: { + bold: '粗體', + italic: '斜體', + code: '程式碼', + link: '連結', + linkPrompt: '輸入連結網址', + headings: '標題', + quote: '引言', + bulletedList: '項目符號清單', + numberedList: '編號清單', + addComponent: '加入元件', richText: 'Rich Text', markdown: 'Markdown', }, diff --git a/packages/netlify-cms-widget-markdown/src/MarkdownControl/Toolbar.js b/packages/netlify-cms-widget-markdown/src/MarkdownControl/Toolbar.js index 3d9b655c..b45c7414 100644 --- a/packages/netlify-cms-widget-markdown/src/MarkdownControl/Toolbar.js +++ b/packages/netlify-cms-widget-markdown/src/MarkdownControl/Toolbar.js @@ -131,7 +131,7 @@ export default class Toolbar extends React.Component { {isVisible('bold') && ( ( { - this.editor.toggleLink(() => window.prompt('Enter the URL of the link')); + this.editor.toggleLink(() => + window.prompt(this.props.t('editor.editorWidgets.markdown.linkPrompt')), + ); }; hasMark = type => this.editor && this.editor.hasMark(type); diff --git a/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins/visual.js b/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins/visual.js index a55139df..85a1ec2e 100644 --- a/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins/visual.js +++ b/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins/visual.js @@ -14,7 +14,7 @@ import Shortcode from './Shortcode'; import { SLATE_DEFAULT_BLOCK_TYPE as defaultType } from '../../types'; import Hotkey, { HOT_KEY_MAP } from './Hotkey'; -const plugins = ({ getAsset, resolveWidget }) => [ +const plugins = ({ getAsset, resolveWidget, t }) => [ { onKeyDown(event, editor, next) { if (isHotkey('mod+j', event)) { @@ -33,7 +33,9 @@ const plugins = ({ getAsset, resolveWidget }) => [ Hotkey(HOT_KEY_MAP['heading-four'], e => e.toggleBlock('heading-four')), Hotkey(HOT_KEY_MAP['heading-five'], e => e.toggleBlock('heading-five')), Hotkey(HOT_KEY_MAP['heading-six'], e => e.toggleBlock('heading-six')), - Hotkey(HOT_KEY_MAP['link'], e => e.toggleLink(() => window.prompt('Enter the URL of the link'))), + Hotkey(HOT_KEY_MAP['link'], e => + e.toggleLink(() => window.prompt(t('editor.editorWidgets.markdown.linkPrompt'))), + ), CommandsAndQueries({ defaultType }), QuoteBlock({ defaultType, type: 'quote' }), ListPlugin({ defaultType, unorderedListType: 'bulleted-list', orderedListType: 'numbered-list' }),