Skip to content

国际化配置

示例代码

typescript
new AiEditor({
    element: "#aiEditor",
    lang: "zh",
    i18n: {
        zh :{
            "undo": "撤销(自定义)",
            "redo": "重做(自定义...)",
        },
        en:{
            "undo": "Undo",
            "redo": "Redo",
        }
    }
})
  • lang:编辑器使用的语言设置。
  • i18n:自定义国际化配置。

注意

AiEditor 已经内置了关于 zh(中文)和 en(英文)的国际化内容,只需要配置 lang 即可,但可以通过 i18n 的配置覆盖掉内置的内容,或者添加额外的其他语言。

添加其他语言的支持

typescript
new AiEditor({
    element: "#aiEditor",
    lang: "otherLang",
    i18n: {
        otherLang :{
            "undo": "xxx",
            "redo": "xxx",
        },
    }
})

切换语言

typescript
const aiEditor = new AiEditor({
    element: "#aiEditor",
    lang: "zh",
    i18n: {
        zh :{
            "undo": "撤销(自定义)",
            "redo": "重做(自定义...)",
        },
        en:{
            "undo": "Undo",
            "redo": "Redo",
        }
    }
})

//切换当前语言到英语
aiEditor.changeLang("en")

Released under the LGPL-v2.1 License.