refactor: flatten locale map

This commit is contained in:
Rongjian Zhang 2021-07-03 11:26:39 +08:00
parent f4567b8ebe
commit 61279f6d00
17 changed files with 382 additions and 476 deletions

View File

@ -31,7 +31,6 @@
"@types/lodash.throttle": "^4.1.6",
"@types/mdast": "^3.0.3",
"codemirror-ssr": "^0.0.6",
"deepmerge": "^4.2.2",
"hast-util-sanitize": "^3.0.2",
"lodash.debounce": "^4.0.8",
"lodash.throttle": "^4.1.1",
@ -42,7 +41,6 @@
"remark-rehype": "^8.1.0",
"select-files": "^1.0.1",
"tippy.js": "^6.3.1",
"tsdef": "^0.0.14",
"unified": "^9.2.1",
"unist-util-visit": "^2.0.3",
"vfile": "^4.2.1",

View File

@ -4,12 +4,7 @@
import type { Editor, KeyMap, Linter, Annotation } from 'codemirror'
import type { Root, Element } from 'hast'
import type { VFile } from 'vfile'
import type {
BytemdEditorContext,
BytemdLocale,
BytemdPlugin,
EditorProps,
} from './types'
import type { BytemdEditorContext, BytemdPlugin, EditorProps } from './types'
import { onMount, createEventDispatcher, onDestroy, tick } from 'svelte'
import debounce from 'lodash.debounce'
import throttle from 'lodash.throttle'
@ -25,7 +20,6 @@
import Status from './status.svelte'
import { icons } from './icons'
import en from './locales/en.json'
import deepmerge from 'deepmerge'
import Help from './help.svelte'
import factory from 'codemirror-ssr'
import usePlaceholder from 'codemirror-ssr/addon/display/placeholder'
@ -51,9 +45,7 @@
export let overridePreview: EditorProps['overridePreview']
export let maxLength: EditorProps['maxLength']
// do deep merge to support incomplete locales, use en as fallback
$: mergedLocale = deepmerge(en, locale ?? {}) as BytemdLocale
const mergedLocale = { ...en, ...locale }
const dispatch = createEventDispatcher()
$: actions = getBuiltinActions(mergedLocale, plugins, uploadImages)

View File

@ -151,11 +151,11 @@ export function getBuiltinActions(
handler: {
type: 'dropdown',
actions: [1, 2, 3, 4, 5, 6].map((level) => ({
title: locale.action[`h${level}` as keyof typeof locale.action],
title: locale[`h${level}` as keyof BytemdLocale],
icon: icons[`h${level}` as keyof typeof icons],
cheatsheet:
level <= 3
? `${'#'.repeat(level)} ${locale.action.headingText}`
? `${'#'.repeat(level)} ${locale.headingText}`
: undefined,
handler: {
type: 'action',
@ -172,9 +172,9 @@ export function getBuiltinActions(
},
},
{
title: locale.action.bold,
title: locale.bold,
icon: icons.bold,
cheatsheet: `**${locale.action.boldText}**`,
cheatsheet: `**${locale.boldText}**`,
handler: {
type: 'action',
shortcut: getShortcutWithPrefix('B'),
@ -185,9 +185,9 @@ export function getBuiltinActions(
},
},
{
title: locale.action.italic,
title: locale.italic,
icon: icons.italic,
cheatsheet: `*${locale.action.italicText}*`,
cheatsheet: `*${locale.italicText}*`,
handler: {
type: 'action',
shortcut: getShortcutWithPrefix('I'),
@ -198,9 +198,9 @@ export function getBuiltinActions(
},
},
{
title: locale.action.quote,
title: locale.quote,
icon: icons.quote,
cheatsheet: `> ${locale.action.quotedText}`,
cheatsheet: `> ${locale.quotedText}`,
handler: {
type: 'action',
click({ replaceLines, editor }) {
@ -210,9 +210,9 @@ export function getBuiltinActions(
},
},
{
title: locale.action.link,
title: locale.link,
icon: icons.link,
cheatsheet: `[${locale.action.linkText}](url)`,
cheatsheet: `[${locale.linkText}](url)`,
handler: {
type: 'action',
shortcut: getShortcutWithPrefix('K'),
@ -228,9 +228,9 @@ export function getBuiltinActions(
},
},
{
title: locale.action.image,
title: locale.image,
icon: icons.image,
cheatsheet: `![${locale.action.imageAlt}](url "${locale.action.imageTitle}")`,
cheatsheet: `![${locale.imageAlt}](url "${locale.imageTitle}")`,
handler: uploadImages
? {
type: 'action',
@ -249,9 +249,9 @@ export function getBuiltinActions(
: undefined,
},
{
title: locale.action.code,
title: locale.code,
icon: icons.code,
cheatsheet: '`' + locale.action.codeText + '`',
cheatsheet: '`' + locale.codeText + '`',
handler: {
type: 'action',
shortcut: getShortcutWithPrefix('K', true),
@ -262,9 +262,9 @@ export function getBuiltinActions(
},
},
{
title: locale.action.codeBlock,
title: locale.codeBlock,
icon: icons.codeBlock,
cheatsheet: '```' + locale.action.codeLang + '↵',
cheatsheet: '```' + locale.codeLang + '↵',
handler: {
type: 'action',
shortcut: getShortcutWithPrefix('C', true),
@ -279,9 +279,9 @@ export function getBuiltinActions(
},
},
{
title: locale.action.ul,
title: locale.ul,
icon: icons.ul,
cheatsheet: `- ${locale.action.ulItem}`,
cheatsheet: `- ${locale.ulItem}`,
handler: {
type: 'action',
shortcut: getShortcutWithPrefix('U', true),
@ -292,9 +292,9 @@ export function getBuiltinActions(
},
},
{
title: locale.action.ol,
title: locale.ol,
icon: icons.ol,
cheatsheet: `1. ${locale.action.olItem}`,
cheatsheet: `1. ${locale.olItem}`,
handler: {
type: 'action',
shortcut: getShortcutWithPrefix('O', true),
@ -305,7 +305,7 @@ export function getBuiltinActions(
},
},
{
title: locale.action.hr,
title: locale.hr,
icon: icons.hr,
cheatsheet: '---',
},

View File

@ -25,7 +25,7 @@
</script>
<div class="bytemd-help" class:bytemd-hidden={!visible}>
<h2>{locale.sidebar.cheatsheet}</h2>
<h2>{locale.cheatsheet}</h2>
<ul>
{#each items as action}
{#if action.cheatsheet}
@ -39,7 +39,7 @@
{/if}
{/each}
</ul>
<h2>{locale.sidebar.shortcuts}</h2>
<h2>{locale.shortcuts}</h2>
<ul>
{#each items as action}
{#if action.handler && action.handler.type === 'action' && action.handler.shortcut}

View File

@ -1,57 +1,48 @@
{
"action": {
"quotedText": "text citat",
"quote": "Cita",
"linkText": "text de lenllaç",
"link": "Enllaç",
"hr": "Línia horitzontal",
"olItem": "element",
"ol": "Llista ordenada",
"ulItem": "element",
"ul": "Llista sense ordenar",
"codeLang": "llenguatge",
"codeBlock": "Bloc de codi",
"codeText": "codi",
"code": "Codi",
"imageTitle": "títol",
"imageAlt": "text alt.",
"image": "Imatge",
"italicText": "text en cursiva",
"italic": "Cursiva",
"boldText": "text en negreta",
"bold": "Negreta",
"headingText": "encapçalament",
"h6": "Encapçalament 6",
"h5": "Encapçalament 5",
"h4": "Encapçalament 4",
"h3": "Encapçalament 3",
"h2": "Encapçalament 2",
"h1": "Encapçalament 1"
},
"sidebar": {
"toc": "Taula de contingut",
"cheatsheet": "Referència ràpida del Markdown",
"shortcuts": "Dreceres"
},
"toolbar": {
"closeToc": "Tanca la taula de contingut",
"toc": "Taula de contingut",
"exitFullscreen": "Surt de la pantalla completa",
"fullscreen": "Pantalla completa",
"source": "Codi font",
"closeHelp": "Tanca lajuda",
"help": "Ajuda",
"exitPreviewOnly": "Surt de «Només previsualització»",
"previewOnly": "Només previsualització",
"exitWriteOnly": "Surt de «Només escriptura»",
"writeOnly": "Només escriptura",
"preview": "Previsualització",
"write": "Escriptura"
},
"status": {
"top": "Desplaçat fins al capdamunt",
"sync": "Desplaçament síncron",
"lines": "Línies",
"words": "Mots"
}
"quotedText": "text citat",
"quote": "Cita",
"linkText": "text de lenllaç",
"link": "Enllaç",
"hr": "Línia horitzontal",
"olItem": "element",
"ol": "Llista ordenada",
"ulItem": "element",
"ul": "Llista sense ordenar",
"codeLang": "llenguatge",
"codeBlock": "Bloc de codi",
"codeText": "codi",
"code": "Codi",
"imageTitle": "títol",
"imageAlt": "text alt.",
"image": "Imatge",
"italicText": "text en cursiva",
"italic": "Cursiva",
"boldText": "text en negreta",
"bold": "Negreta",
"headingText": "encapçalament",
"h6": "Encapçalament 6",
"h5": "Encapçalament 5",
"h4": "Encapçalament 4",
"h3": "Encapçalament 3",
"h2": "Encapçalament 2",
"h1": "Encapçalament 1",
"toc": "Taula de contingut",
"cheatsheet": "Referència ràpida del Markdown",
"shortcuts": "Dreceres",
"closeToc": "Tanca la taula de contingut",
"exitFullscreen": "Surt de la pantalla completa",
"fullscreen": "Pantalla completa",
"source": "Codi font",
"closeHelp": "Tanca lajuda",
"help": "Ajuda",
"exitPreviewOnly": "Surt de «Només previsualització»",
"previewOnly": "Només previsualització",
"exitWriteOnly": "Surt de «Només escriptura»",
"writeOnly": "Només escriptura",
"preview": "Previsualització",
"write": "Escriptura",
"top": "Desplaçat fins al capdamunt",
"sync": "Desplaçament síncron",
"lines": "Línies",
"words": "Mots"
}

View File

@ -1,58 +1,49 @@
{
"toolbar": {
"write": "Write",
"preview": "Preview",
"writeOnly": "Write only",
"exitWriteOnly": "Exit write only",
"previewOnly": "Preview only",
"exitPreviewOnly": "Exit preview only",
"help": "Help",
"closeHelp": "Close help",
"toc": "Table of contents",
"closeToc": "Close table of contents",
"fullscreen": "Fullscreen",
"exitFullscreen": "Exit fullscreen",
"source": "Source code"
},
"sidebar": {
"toc": "Table of contents",
"cheatsheet": "Markdown Cheatsheet",
"shortcuts": "Shortcuts"
},
"status": {
"words": "Words",
"lines": "Lines",
"sync": "Scroll sync",
"top": "Scroll to top",
"limited": "The maximum character limit has been reached"
},
"action": {
"h1": "Heading 1",
"h2": "Heading 2",
"h3": "Heading 3",
"h4": "Heading 4",
"h5": "Heading 5",
"h6": "Heading 6",
"headingText": "heading",
"bold": "Bold",
"boldText": "bold text",
"italic": "Italic",
"italicText": "italic text",
"quote": "Quote",
"quotedText": "quoted text",
"link": "Link",
"linkText": "link text",
"image": "Image",
"imageAlt": "alt",
"imageTitle": "title",
"code": "Code",
"codeText": "code",
"codeBlock": "Code block",
"codeLang": "lang",
"ul": "Unordered list",
"ulItem": "item",
"ol": "Ordered list",
"olItem": "item",
"hr": "Horizontal rule"
}
"write": "Write",
"preview": "Preview",
"writeOnly": "Write only",
"exitWriteOnly": "Exit write only",
"previewOnly": "Preview only",
"exitPreviewOnly": "Exit preview only",
"help": "Help",
"closeHelp": "Close help",
"toc": "Table of contents",
"closeToc": "Close table of contents",
"fullscreen": "Fullscreen",
"exitFullscreen": "Exit fullscreen",
"source": "Source code",
"cheatsheet": "Markdown Cheatsheet",
"shortcuts": "Shortcuts",
"words": "Words",
"lines": "Lines",
"sync": "Scroll sync",
"top": "Scroll to top",
"limited": "The maximum character limit has been reached",
"h1": "Heading 1",
"h2": "Heading 2",
"h3": "Heading 3",
"h4": "Heading 4",
"h5": "Heading 5",
"h6": "Heading 6",
"headingText": "heading",
"bold": "Bold",
"boldText": "bold text",
"italic": "Italic",
"italicText": "italic text",
"quote": "Quote",
"quotedText": "quoted text",
"link": "Link",
"linkText": "link text",
"image": "Image",
"imageAlt": "alt",
"imageTitle": "title",
"code": "Code",
"codeText": "code",
"codeBlock": "Code block",
"codeLang": "lang",
"ul": "Unordered list",
"ulItem": "item",
"ol": "Ordered list",
"olItem": "item",
"hr": "Horizontal rule"
}

View File

@ -1,57 +1,48 @@
{
"toolbar": {
"write": "Escribir",
"source": "Código fuente",
"exitFullscreen": "Salir de pantalla completa",
"fullscreen": "Pantalla completa",
"closeToc": "Cerrar sumario",
"toc": "Sumario",
"help": "Ayuda",
"preview": "Previsualizar",
"closeHelp": "Cerrar ayuda",
"previewOnly": "Solo previsualización",
"writeOnly": "Solo escritura",
"exitPreviewOnly": "Salir de Solo previsualización",
"exitWriteOnly": "Salir de Solo escritura"
},
"action": {
"hr": "Línea horizontal",
"linkText": "texto de enlace",
"link": "Enlace",
"quotedText": "texto citado",
"quote": "Cita",
"codeBlock": "Bloque de código",
"codeText": "código",
"code": "Código",
"image": "Imagen",
"italicText": "texto en itálicas",
"italic": "Itálica",
"boldText": "texto en negritas",
"bold": "Negrita",
"headingText": "título",
"h6": "Título 6",
"h5": "Título 5",
"h4": "Título 4",
"h3": "Título 3",
"h2": "Título 2",
"h1": "Título 1",
"olItem": "elemento",
"ol": "Lista numerada",
"ulItem": "elemento",
"ul": "Lista con bolos",
"codeLang": "lenguaje",
"imageTitle": "título",
"imageAlt": "texto alt."
},
"sidebar": {
"cheatsheet": "Referencia rápida de Markdown",
"shortcuts": "Atajos",
"toc": "Sumario"
},
"status": {
"sync": "Desplazamiento síncrono",
"lines": "Renglones",
"words": "Palabras",
"top": "Desplazarse hasta arriba"
}
"write": "Escribir",
"source": "Código fuente",
"exitFullscreen": "Salir de pantalla completa",
"fullscreen": "Pantalla completa",
"closeToc": "Cerrar sumario",
"toc": "Sumario",
"help": "Ayuda",
"preview": "Previsualizar",
"closeHelp": "Cerrar ayuda",
"previewOnly": "Solo previsualización",
"writeOnly": "Solo escritura",
"exitPreviewOnly": "Salir de Solo previsualización",
"exitWriteOnly": "Salir de Solo escritura",
"hr": "Línea horizontal",
"linkText": "texto de enlace",
"link": "Enlace",
"quotedText": "texto citado",
"quote": "Cita",
"codeBlock": "Bloque de código",
"codeText": "código",
"code": "Código",
"image": "Imagen",
"italicText": "texto en itálicas",
"italic": "Itálica",
"boldText": "texto en negritas",
"bold": "Negrita",
"headingText": "título",
"h6": "Título 6",
"h5": "Título 5",
"h4": "Título 4",
"h3": "Título 3",
"h2": "Título 2",
"h1": "Título 1",
"olItem": "elemento",
"ol": "Lista numerada",
"ulItem": "elemento",
"ul": "Lista con bolos",
"codeLang": "lenguaje",
"imageTitle": "título",
"imageAlt": "texto alt.",
"cheatsheet": "Referencia rápida de Markdown",
"shortcuts": "Atajos",
"sync": "Desplazamiento síncrono",
"lines": "Renglones",
"words": "Palabras",
"top": "Desplazarse hasta arriba"
}

View File

@ -1,57 +1,48 @@
{
"sidebar": {
"cheatsheet": "マークダウン カンニングペーパー",
"shortcuts": "ショートカット",
"toc": "目次"
},
"status": {
"lines": "線",
"top": "トップにスクロールします",
"sync": "スクロール同期",
"words": "言葉"
},
"toolbar": {
"preview": "プレビュー",
"exitPreviewOnly": "プレビューのみを終了",
"source": "原始コード",
"exitFullscreen": "全画面を閉じます",
"fullscreen": "全画面",
"closeToc": "目次を閉じます",
"toc": "目次",
"help": "ヘルプビューア",
"closeHelp": "ヘルプビューアを閉じます",
"previewOnly": "試写専用",
"exitWriteOnly": "Exit 書き込み専用",
"writeOnly": "書き込み専用",
"write": "書く"
},
"action": {
"hr": "区切り線",
"olItem": "アイテム",
"ol": "番号付きリスト",
"ulItem": "アイテム",
"ul": "順序なしリスト",
"codeLang": "lang",
"codeBlock": "コードブロック",
"codeText": "コード",
"code": "コード",
"imageTitle": "タイトル",
"imageAlt": "alt",
"image": "イメージ",
"linkText": "リンクテキスト",
"link": "リンク",
"quotedText": "引用テキスト",
"quote": "見積もり",
"italicText": "斜体のテキスト",
"italic": "イタリック",
"boldText": "ボールドテキスト",
"bold": "太字",
"headingText": "見出し",
"h6": "見出し6",
"h5": "見出し5",
"h3": "見出し3",
"h4": "見出し4",
"h2": "見出し2",
"h1": "見出し1"
}
"cheatsheet": "マークダウン カンニングペーパー",
"shortcuts": "ショートカット",
"toc": "目次",
"lines": "線",
"top": "トップにスクロールします",
"sync": "スクロール同期",
"words": "言葉",
"preview": "プレビュー",
"exitPreviewOnly": "プレビューのみを終了",
"source": "原始コード",
"exitFullscreen": "全画面を閉じます",
"fullscreen": "全画面",
"closeToc": "目次を閉じます",
"help": "ヘルプビューア",
"closeHelp": "ヘルプビューアを閉じます",
"previewOnly": "試写専用",
"exitWriteOnly": "Exit 書き込み専用",
"writeOnly": "書き込み専用",
"write": "書く",
"hr": "区切り線",
"olItem": "アイテム",
"ol": "番号付きリスト",
"ulItem": "アイテム",
"ul": "順序なしリスト",
"codeLang": "lang",
"codeBlock": "コードブロック",
"codeText": "コード",
"code": "コード",
"imageTitle": "タイトル",
"imageAlt": "alt",
"image": "イメージ",
"linkText": "リンクテキスト",
"link": "リンク",
"quotedText": "引用テキスト",
"quote": "見積もり",
"italicText": "斜体のテキスト",
"italic": "イタリック",
"boldText": "ボールドテキスト",
"bold": "太字",
"headingText": "見出し",
"h6": "見出し6",
"h5": "見出し5",
"h3": "見出し3",
"h4": "見出し4",
"h2": "見出し2",
"h1": "見出し1"
}

View File

@ -1,23 +1,17 @@
{
"toolbar": {
"exitPreviewOnly": "미리보기 전용 종료",
"previewOnly": "미리보기 전용",
"exitWriteOnly": "쓰기 전용 종료",
"writeOnly": "쓰기 전용",
"source": "소스 코드",
"exitFullscreen": "꽉 찬 화면 종료",
"fullscreen": "꽉 찬 화면",
"closeHelp": "도움말 닫기",
"help": "도움말",
"preview": "미리보기",
"write": "작성"
},
"action": {
"image": "이미지",
"link": "링크"
},
"status": {
"top": "맨 위로 스크롤",
"sync": "스크롤 동기화"
}
"exitPreviewOnly": "미리보기 전용 종료",
"previewOnly": "미리보기 전용",
"exitWriteOnly": "쓰기 전용 종료",
"writeOnly": "쓰기 전용",
"source": "소스 코드",
"exitFullscreen": "꽉 찬 화면 종료",
"fullscreen": "꽉 찬 화면",
"closeHelp": "도움말 닫기",
"help": "도움말",
"preview": "미리보기",
"write": "작성",
"image": "이미지",
"link": "링크",
"top": "맨 위로 스크롤",
"sync": "스크롤 동기화"
}

View File

@ -1,54 +1,45 @@
{
"action": {
"ol": "Нумерованный список",
"codeLang": "язык",
"codeBlock": "Блок кода",
"codeText": "код",
"code": "Код",
"image": "Изображение",
"linkText": "текст ссылки",
"link": "Ссылка",
"quotedText": "цитируемый текст",
"quote": "Цитата",
"italicText": "курсивный текст",
"italic": "Курсив",
"boldText": "жирный текст",
"bold": "Жирный",
"headingText": "заголовок",
"h6": "Заголовок 6",
"h5": "Заголовок 5",
"h4": "Заголовок 4",
"h3": "Заголовок 3",
"h2": "Заголовок 2",
"h1": "Заголовок 1",
"olItem": "элемент",
"ulItem": "элемент",
"imageTitle": "название",
"ul": "Маркированный список"
},
"status": {
"sync": "Синхронизация прокрутки",
"words": "Слова",
"top": "Пролистать наверх",
"lines": "Строки"
},
"toolbar": {
"source": "Исходный код",
"fullscreen": "Полноэкранный режим",
"exitFullscreen": "Выйти из полноэкранного режима",
"closeToc": "Закрыть оглавление",
"toc": "Оглавление",
"closeHelp": "Закрыть справку",
"help": "Справка",
"previewOnly": "Только предпросмотр",
"preview": "Предпросмотр",
"exitPreviewOnly": "Выйти из режима предпросмотра",
"writeOnly": "Только запись",
"write": "Записать"
},
"sidebar": {
"shortcuts": "Горячие клавиши",
"cheatsheet": "Шпаргалка по Markdown",
"toc": "Оглавление"
}
"ol": "Нумерованный список",
"codeLang": "язык",
"codeBlock": "Блок кода",
"codeText": "код",
"code": "Код",
"image": "Изображение",
"linkText": "текст ссылки",
"link": "Ссылка",
"quotedText": "цитируемый текст",
"quote": "Цитата",
"italicText": "курсивный текст",
"italic": "Курсив",
"boldText": "жирный текст",
"bold": "Жирный",
"headingText": "заголовок",
"h6": "Заголовок 6",
"h5": "Заголовок 5",
"h4": "Заголовок 4",
"h3": "Заголовок 3",
"h2": "Заголовок 2",
"h1": "Заголовок 1",
"olItem": "элемент",
"ulItem": "элемент",
"imageTitle": "название",
"ul": "Маркированный список",
"sync": "Синхронизация прокрутки",
"words": "Слова",
"top": "Пролистать наверх",
"lines": "Строки",
"source": "Исходный код",
"fullscreen": "Полноэкранный режим",
"exitFullscreen": "Выйти из полноэкранного режима",
"closeToc": "Закрыть оглавление",
"toc": "Оглавление",
"closeHelp": "Закрыть справку",
"help": "Справка",
"previewOnly": "Только предпросмотр",
"preview": "Предпросмотр",
"exitPreviewOnly": "Выйти из режима предпросмотра",
"writeOnly": "Только запись",
"write": "Записать",
"shortcuts": "Горячие клавиши",
"cheatsheet": "Шпаргалка по Markdown"
}

View File

@ -1,58 +1,49 @@
{
"toolbar": {
"preview": "预览",
"write": "编辑",
"source": "源代码",
"exitFullscreen": "退出全屏",
"fullscreen": "全屏",
"closeToc": "关闭目录",
"toc": "目录",
"closeHelp": "关闭帮助",
"help": "帮助",
"exitPreviewOnly": "恢复默认",
"previewOnly": "仅预览区",
"exitWriteOnly": "恢复默认",
"writeOnly": "仅编辑区"
},
"action": {
"hr": "分割线",
"olItem": "项目",
"ol": "有序列表",
"ulItem": "项目",
"ul": "无序列表",
"codeLang": "编程语言",
"codeBlock": "代码块",
"codeText": "代码",
"code": "代码",
"imageTitle": "图片描述",
"imageAlt": "alt",
"image": "图片",
"linkText": "链接描述",
"link": "链接",
"quotedText": "引用文本",
"quote": "引用",
"italicText": "斜体文本",
"italic": "斜体",
"boldText": "粗体文本",
"bold": "粗体",
"headingText": "标题",
"h6": "六级标题",
"h5": "五级标题",
"h4": "四级标题",
"h3": "三级标题",
"h2": "二级标题",
"h1": "一级标题"
},
"status": {
"top": "回到顶部",
"sync": "同步滚动",
"lines": "行数",
"words": "字数",
"limited": "已达最大字符数限制"
},
"sidebar": {
"shortcuts": "快捷键",
"cheatsheet": "Markdown 语法",
"toc": "目录"
}
"preview": "预览",
"write": "编辑",
"source": "源代码",
"exitFullscreen": "退出全屏",
"fullscreen": "全屏",
"closeToc": "关闭目录",
"toc": "目录",
"closeHelp": "关闭帮助",
"help": "帮助",
"exitPreviewOnly": "恢复默认",
"previewOnly": "仅预览区",
"exitWriteOnly": "恢复默认",
"writeOnly": "仅编辑区",
"hr": "分割线",
"olItem": "项目",
"ol": "有序列表",
"ulItem": "项目",
"ul": "无序列表",
"codeLang": "编程语言",
"codeBlock": "代码块",
"codeText": "代码",
"code": "代码",
"imageTitle": "图片描述",
"imageAlt": "alt",
"image": "图片",
"linkText": "链接描述",
"link": "链接",
"quotedText": "引用文本",
"quote": "引用",
"italicText": "斜体文本",
"italic": "斜体",
"boldText": "粗体文本",
"bold": "粗体",
"headingText": "标题",
"h6": "六级标题",
"h5": "五级标题",
"h4": "四级标题",
"h3": "三级标题",
"h2": "二级标题",
"h1": "一级标题",
"top": "回到顶部",
"sync": "同步滚动",
"lines": "行数",
"words": "字数",
"limited": "已达最大字符数限制",
"shortcuts": "快捷键",
"cheatsheet": "Markdown 语法"
}

View File

@ -1,57 +1,48 @@
{
"action": {
"imageAlt": "alt",
"hr": "分割線",
"olItem": "項目",
"ol": "定義列表",
"ulItem": "項目",
"ul": "無序列表",
"codeLang": "編程語言",
"codeBlock": "代碼塊",
"codeText": "代碼",
"code": "代碼",
"imageTitle": "圖像描述",
"image": "圖像",
"linkText": "連結描述",
"link": "連結",
"quotedText": "引用文本",
"quote": "引用",
"italicText": "斜體字",
"italic": "斜體",
"boldText": "粗體字",
"bold": "粗體",
"headingText": "標題",
"h6": "六級標題",
"h5": "五級標題",
"h4": "四級標題",
"h3": "三級標題",
"h2": "二級標題",
"h1": "一級標題"
},
"status": {
"top": "回到頂部",
"sync": "同步滾動",
"lines": "行數",
"words": "字數"
},
"sidebar": {
"shortcuts": "快捷鍵",
"cheatsheet": "Markdown 語法",
"toc": "目錄"
},
"toolbar": {
"source": "源碼",
"exitFullscreen": "退出全屏",
"fullscreen": "全屏",
"closeToc": "關閉目錄",
"toc": "目錄",
"closeHelp": "關閉幫助",
"help": "幫助",
"exitPreviewOnly": "恢復默認",
"previewOnly": "僅預覽區",
"exitWriteOnly": "恢復默認",
"writeOnly": "僅編輯區",
"preview": "預覽",
"write": "編輯"
}
"imageAlt": "alt",
"hr": "分割線",
"olItem": "項目",
"ol": "定義列表",
"ulItem": "項目",
"ul": "無序列表",
"codeLang": "編程語言",
"codeBlock": "代碼塊",
"codeText": "代碼",
"code": "代碼",
"imageTitle": "圖像描述",
"image": "圖像",
"linkText": "連結描述",
"link": "連結",
"quotedText": "引用文本",
"quote": "引用",
"italicText": "斜體字",
"italic": "斜體",
"boldText": "粗體字",
"bold": "粗體",
"headingText": "標題",
"h6": "六級標題",
"h5": "五級標題",
"h4": "四級標題",
"h3": "三級標題",
"h2": "二級標題",
"h1": "一級標題",
"top": "回到頂部",
"sync": "同步滾動",
"lines": "行數",
"words": "字數",
"shortcuts": "快捷鍵",
"cheatsheet": "Markdown 語法",
"toc": "目錄",
"source": "源碼",
"exitFullscreen": "退出全屏",
"fullscreen": "全屏",
"closeToc": "關閉目錄",
"closeHelp": "關閉幫助",
"help": "幫助",
"exitPreviewOnly": "恢復默認",
"previewOnly": "僅預覽區",
"exitWriteOnly": "恢復默認",
"writeOnly": "僅編輯區",
"preview": "預覽",
"write": "編輯"
}

View File

@ -18,13 +18,13 @@
<div class="bytemd-status">
<div class="bytemd-status-left">
<span>
{locale.status.words}: <strong>{words}</strong>
{locale.words}: <strong>{words}</strong>
</span>
<span>
{locale.status.lines}: <strong>{lines}</strong>
{locale.lines}: <strong>{lines}</strong>
</span>
{#if islimited}
<span class="danger">{locale.status.limited}</span>
<span class="danger">{locale.limited}</span>
{/if}
</div>
@ -36,9 +36,9 @@
checked={syncEnabled}
on:change={() => dispatch('sync', !syncEnabled)}
/>
{locale.status.sync}
{locale.sync}
</label>
{/if}
<span on:click={() => dispatch('top')}>{locale.status.top}</span>
<span on:click={() => dispatch('top')}>{locale.top}</span>
</div>
</div>

View File

@ -53,7 +53,7 @@
</script>
<div class="bytemd-toc" class:bytemd-hidden={!visible}>
<h2>{locale.sidebar.toc}</h2>
<h2>{locale.toc}</h2>
<ul>
{#each items as item, index}
<li

View File

@ -66,7 +66,7 @@
// },
// },
{
title: tocActive ? locale.toolbar.closeToc : locale.toolbar.toc,
title: tocActive ? locale.closeToc : locale.toc,
icon: icons.toc,
handler: {
type: 'action',
@ -77,7 +77,7 @@
active: tocActive,
},
{
title: helpActive ? locale.toolbar.closeHelp : locale.toolbar.help,
title: helpActive ? locale.closeHelp : locale.help,
icon: icons.help,
handler: {
type: 'action',
@ -88,9 +88,7 @@
active: helpActive,
},
{
title: writeActive
? locale.toolbar.exitWriteOnly
: locale.toolbar.writeOnly,
title: writeActive ? locale.exitWriteOnly : locale.writeOnly,
icon: icons.left,
handler: {
type: 'action',
@ -102,9 +100,7 @@
hidden: !split,
},
{
title: previewActive
? locale.toolbar.exitPreviewOnly
: locale.toolbar.previewOnly,
title: previewActive ? locale.exitPreviewOnly : locale.previewOnly,
icon: icons.right,
handler: {
type: 'action',
@ -116,9 +112,7 @@
hidden: !split,
},
{
title: fullscreen
? locale.toolbar.exitFullscreen
: locale.toolbar.fullscreen,
title: fullscreen ? locale.exitFullscreen : locale.fullscreen,
icon: fullscreen ? icons.fullscreenOff : icons.fullscreenOn,
handler: {
type: 'action',
@ -128,7 +122,7 @@
},
},
{
title: locale.toolbar.source,
title: locale.source,
icon: icons.source,
handler: {
type: 'action',
@ -299,14 +293,14 @@
class="bytemd-toolbar-tab"
class:bytemd-toolbar-tab-active={activeTab !== 'preview'}
>
{locale.toolbar.write}
{locale.write}
</div>
<div
on:click={() => dispatch('tab', 'preview')}
class="bytemd-toolbar-tab"
class:bytemd-toolbar-tab-active={activeTab === 'preview'}
>
{locale.toolbar.preview}
{locale.preview}
</div>
<!-- <div class={['bytemd-toolbar-icon', tippyClass].join(' ')}>
{@html icons.more}

View File

@ -6,7 +6,6 @@ import type CodeMirror from 'codemirror'
import type { EditorUtils } from './editor'
import type en from './locales/en.json'
import type { Image } from 'mdast'
import type { DeepPartial } from 'tsdef'
export type BytemdLocale = typeof en
@ -144,7 +143,7 @@ export interface EditorProps extends ViewerProps {
*
* @defaultValue en
*/
locale?: DeepPartial<BytemdLocale>
locale?: Partial<BytemdLocale>
/**
* Handle images upload
*/

View File

@ -208,8 +208,8 @@ importers:
'@bytemd/plugin-mermaid': link:../../packages/plugin-mermaid
bytemd: link:../../packages/bytemd
devDependencies:
'@sveltejs/adapter-node': 1.0.0-next.29
'@sveltejs/kit': 1.0.0-next.119_rollup@2.52.7+svelte@3.38.2
'@sveltejs/adapter-node': 1.0.0-next.30
'@sveltejs/kit': 1.0.0-next.120_rollup@2.52.7+svelte@3.38.2
sass: 1.32.12
svelte: 3.38.2
svelte-preprocess: 4.7.3_0f957d27398e96725816240c3a3a5bfb
@ -307,7 +307,6 @@ importers:
'@types/lodash.throttle': ^4.1.6
'@types/mdast': ^3.0.3
codemirror-ssr: ^0.0.6
deepmerge: ^4.2.2
hast-util-sanitize: ^3.0.2
lodash.debounce: ^4.0.8
lodash.throttle: ^4.1.1
@ -318,7 +317,6 @@ importers:
remark-rehype: ^8.1.0
select-files: ^1.0.1
tippy.js: ^6.3.1
tsdef: ^0.0.14
unified: ^9.2.1
unist-util-visit: ^2.0.3
vfile: ^4.2.1
@ -330,7 +328,6 @@ importers:
'@types/lodash.throttle': 4.1.6
'@types/mdast': 3.0.3
codemirror-ssr: 0.0.6
deepmerge: 4.2.2
hast-util-sanitize: 3.0.2
lodash.debounce: 4.0.8
lodash.throttle: 4.1.1
@ -341,7 +338,6 @@ importers:
remark-rehype: 8.1.0
select-files: 1.0.1
tippy.js: 6.3.1
tsdef: 0.0.14
unified: 9.2.1
unist-util-visit: 2.0.3
vfile: 4.2.1
@ -4479,15 +4475,15 @@ packages:
'@sinonjs/commons': 1.8.3
dev: true
/@sveltejs/adapter-node/1.0.0-next.29:
resolution: {integrity: sha512-F773SXfSUGZVtwVvi495uXK71oAZlLF1ZvnLi/R2bcCoDN5y8RA7fSWfrMH78EyM9dLOB5RSdShv8PcE5tpMUg==}
/@sveltejs/adapter-node/1.0.0-next.30:
resolution: {integrity: sha512-DTvazMWs0h5zG++uaT7Yg0JkWfqU8htu3EYFsKh+oeDMviJ8SRXTXSZFtBGr2ltyPBwKUvgEoUYITOl1NHimKQ==}
dependencies:
esbuild: 0.12.12
tiny-glob: 0.2.9
dev: true
/@sveltejs/kit/1.0.0-next.119_rollup@2.52.7+svelte@3.38.2:
resolution: {integrity: sha512-Pp971N1m2yKQg01kUxwQAolhUb1y9NNPV7zfQLIHQdvlFwrNI5hvOMlGiHj26mM5AyQSU4pnH8X1YUPSqi57gw==}
/@sveltejs/kit/1.0.0-next.120_rollup@2.52.7+svelte@3.38.2:
resolution: {integrity: sha512-1sVhlF9zea9Er6abAjqRefQ1mIE9AjtYdRek3ilUTQ44FM2w/e8VgZCo5XXbnz9M564OaZnihyS9XjINlu4Chg==}
engines: {node: ^12.20 || >=14.13}
hasBin: true
peerDependencies:
@ -16654,10 +16650,6 @@ packages:
typescript: 4.3.5
dev: false
/tsdef/0.0.14:
resolution: {integrity: sha512-UjMD4XKRWWFlFBfwKVQmGFT5YzW/ZaF8x6KpCDf92u9wgKeha/go3FU0e5WqDjXsCOdfiavCkfwfVHNDxRDGMA==}
dev: false
/tslib/1.14.1:
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}