From c9125635eae8cecf4bdeda56455b66221c2f1db3 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Wed, 8 Feb 2023 20:59:53 +0800 Subject: [PATCH] docs:add i18n --- docs/.vitepress/config.ts | 1 + docs/guide/command-execute.md | 8 ++++ docs/guide/i18n.md | 81 +++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 docs/guide/i18n.md diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 911f2de..042608b 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -25,6 +25,7 @@ export default defineConfig({ items: [ { text: '入门', link: '/guide/start' }, { text: '配置', link: '/guide/option' }, + { text: '国际化', link: '/guide/i18n' }, { text: '数据结构', link: '/guide/schema' } ] }, diff --git a/docs/guide/command-execute.md b/docs/guide/command-execute.md index decd6db..8f39b1a 100644 --- a/docs/guide/command-execute.md +++ b/docs/guide/command-execute.md @@ -526,4 +526,12 @@ instance.command.executeInsertElementList(IElement[]) 用法: ```javascript instance.command.executeRemoveControl() +``` + +## executeSetLocale +功能:设置本地语言 + +用法: +```javascript +instance.command.executeSetLocale(locale) ``` \ No newline at end of file diff --git a/docs/guide/i18n.md b/docs/guide/i18n.md new file mode 100644 index 0000000..0922bc3 --- /dev/null +++ b/docs/guide/i18n.md @@ -0,0 +1,81 @@ +# 国际化 + +## 使用方式 + +```javascript +import Editor from "@hufe921/canvas-editor" + +const instance = new Editor(container, data, options) + +// 注册 +instance.register.langMap(locale: string, lang: ILang) + +// 设置 +instance.command.executeSetLocale(locale) +``` + +## ILang + +```typescript +interface ILang { + contextmenu: { + global: { + cut: string; + copy: string; + paste: string; + selectAll: string; + print: string; + }; + control: { + delete: string; + }; + hyperlink: { + delete: string; + cancel: string; + edit: string; + }; + image: { + change: string; + saveAs: string; + textWrap: string; + textWrapType: { + embed: string; + upDown: string; + } + }; + table: { + insertRowCol: string; + insertTopRow: string; + insertBottomRow: string; + insertLeftCol: string; + insertRightCol: string; + deleteRowCol: string; + deleteRow: string; + deleteCol: string; + deleteTable: string; + mergeCell: string; + mergeCancelCell: string; + }; + }; + datePicker: { + now: string; + confirm: string; + return: string; + timeSelect: string; + weeks: { + sun: string; + mon: string; + tue: string; + wed: string; + thu: string; + fri: string; + sat: string; + }; + year: string; + month: string; + hour: string; + minute: string; + second: string; + }; +} +``` \ No newline at end of file