fix(locale): remove hard coded strings (#4432)
This commit is contained in:
parent
471e879b78
commit
a5750d782e
@ -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',
|
||||
},
|
||||
|
@ -134,6 +134,16 @@ const zh_Hant = {
|
||||
},
|
||||
editorWidgets: {
|
||||
markdown: {
|
||||
bold: '粗體',
|
||||
italic: '斜體',
|
||||
code: '程式碼',
|
||||
link: '連結',
|
||||
linkPrompt: '輸入連結網址',
|
||||
headings: '標題',
|
||||
quote: '引言',
|
||||
bulletedList: '項目符號清單',
|
||||
numberedList: '編號清單',
|
||||
addComponent: '加入元件',
|
||||
richText: 'Rich Text',
|
||||
markdown: 'Markdown',
|
||||
},
|
||||
|
@ -131,7 +131,7 @@ export default class Toolbar extends React.Component {
|
||||
{isVisible('bold') && (
|
||||
<ToolbarButton
|
||||
type="bold"
|
||||
label="Bold"
|
||||
label={t('editor.editorWidgets.markdown.bold')}
|
||||
icon="bold"
|
||||
onClick={this.handleMarkClick}
|
||||
isActive={hasMark('bold')}
|
||||
@ -141,7 +141,7 @@ export default class Toolbar extends React.Component {
|
||||
{isVisible('italic') && (
|
||||
<ToolbarButton
|
||||
type="italic"
|
||||
label="Italic"
|
||||
label={t('editor.editorWidgets.markdown.italic')}
|
||||
icon="italic"
|
||||
onClick={this.handleMarkClick}
|
||||
isActive={hasMark('italic')}
|
||||
@ -151,7 +151,7 @@ export default class Toolbar extends React.Component {
|
||||
{isVisible('code') && (
|
||||
<ToolbarButton
|
||||
type="code"
|
||||
label="Code"
|
||||
label={t('editor.editorWidgets.markdown.code')}
|
||||
icon="code"
|
||||
onClick={this.handleMarkClick}
|
||||
isActive={hasMark('code')}
|
||||
@ -161,7 +161,7 @@ export default class Toolbar extends React.Component {
|
||||
{isVisible('link') && (
|
||||
<ToolbarButton
|
||||
type="link"
|
||||
label="Link"
|
||||
label={t('editor.editorWidgets.markdown.link')}
|
||||
icon="link"
|
||||
onClick={onLinkClick}
|
||||
isActive={hasInline('link')}
|
||||
@ -178,7 +178,7 @@ export default class Toolbar extends React.Component {
|
||||
<DropdownButton>
|
||||
<ToolbarButton
|
||||
type="headings"
|
||||
label="Headings"
|
||||
label={t('editor.editorWidgets.markdown.headings')}
|
||||
icon="hOptions"
|
||||
disabled={disabled}
|
||||
isActive={!disabled && Object.keys(headingOptions).some(hasBlock)}
|
||||
@ -204,7 +204,7 @@ export default class Toolbar extends React.Component {
|
||||
{isVisible('quote') && (
|
||||
<ToolbarButton
|
||||
type="quote"
|
||||
label="Quote"
|
||||
label={t('editor.editorWidgets.markdown.quote')}
|
||||
icon="quote"
|
||||
onClick={this.handleBlockClick}
|
||||
isActive={hasBlock('quote')}
|
||||
@ -214,7 +214,7 @@ export default class Toolbar extends React.Component {
|
||||
{isVisible('bulleted-list') && (
|
||||
<ToolbarButton
|
||||
type="bulleted-list"
|
||||
label="Bulleted List"
|
||||
label={t('editor.editorWidgets.markdown.bulletedList')}
|
||||
icon="list-bulleted"
|
||||
onClick={this.handleBlockClick}
|
||||
isActive={hasBlock('bulleted-list')}
|
||||
@ -224,7 +224,7 @@ export default class Toolbar extends React.Component {
|
||||
{isVisible('numbered-list') && (
|
||||
<ToolbarButton
|
||||
type="numbered-list"
|
||||
label="Numbered List"
|
||||
label={t('editor.editorWidgets.markdown.numberedList')}
|
||||
icon="list-numbered"
|
||||
onClick={this.handleBlockClick}
|
||||
isActive={hasBlock('numbered-list')}
|
||||
@ -239,7 +239,7 @@ export default class Toolbar extends React.Component {
|
||||
renderButton={() => (
|
||||
<DropdownButton>
|
||||
<ToolbarButton
|
||||
label="Add Component"
|
||||
label={t('editor.editorWidgets.markdown.addComponent')}
|
||||
icon="add-with"
|
||||
onClick={this.handleComponentsMenuToggle}
|
||||
disabled={disabled}
|
||||
|
@ -101,7 +101,11 @@ export default class Editor extends React.Component {
|
||||
this.renderInline = renderInline();
|
||||
this.renderMark = renderMark();
|
||||
this.schema = schema({ voidCodeBlock: !!this.codeBlockComponent });
|
||||
this.plugins = plugins({ getAsset: props.getAsset, resolveWidget: props.resolveWidget });
|
||||
this.plugins = plugins({
|
||||
getAsset: props.getAsset,
|
||||
resolveWidget: props.resolveWidget,
|
||||
t: props.t,
|
||||
});
|
||||
this.state = {
|
||||
value: createSlateValue(this.props.value, { voidCodeBlock: !!this.codeBlockComponent }),
|
||||
};
|
||||
@ -150,7 +154,9 @@ export default class Editor extends React.Component {
|
||||
};
|
||||
|
||||
handleLinkClick = () => {
|
||||
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);
|
||||
|
@ -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' }),
|
||||
|
Loading…
x
Reference in New Issue
Block a user