From 9f815970f8c3c6dddb6bf846ecb672325e80444b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=A6=8F=E6=9C=8B?= Date: Mon, 21 Feb 2022 17:47:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20i18n=20-=20=E8=8E=B7=E5=8F=96=E5=A4=9A?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/i18n/index.ts | 13 ++++++++++++- packages/editor/src/index.ts | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/core/src/i18n/index.ts b/packages/core/src/i18n/index.ts index bc0de384f..e9a3b9204 100644 --- a/packages/core/src/i18n/index.ts +++ b/packages/core/src/i18n/index.ts @@ -5,6 +5,9 @@ import i18next from 'i18next' +// i18n nameSpace +const NS = 'translation' + i18next.init({ lng: 'zh-CN', // debug: true, @@ -17,7 +20,7 @@ i18next.init({ * @param resources 多语言配置 */ export function i18nAddResources(lng: string, resources: object) { - i18next.addResourceBundle(lng, 'translation', resources, true, true) + i18next.addResourceBundle(lng, NS, resources, true, true) } /** @@ -28,6 +31,14 @@ export function i18nChangeLanguage(lng: string) { i18next.changeLanguage(lng) } +/** + * 获取多语言配置 + * @param lng lang + */ +export function i18nGetResources(lng: string) { + return i18next.getResourceBundle(lng, NS) +} + /** * 翻译 */ diff --git a/packages/editor/src/index.ts b/packages/editor/src/index.ts index 68525e8dc..a8c475b86 100644 --- a/packages/editor/src/index.ts +++ b/packages/editor/src/index.ts @@ -31,6 +31,7 @@ export { Toolbar, i18nChangeLanguage, i18nAddResources, + i18nGetResources, t, } from '@wangeditor/core'