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'