Skip to content

Commit

Permalink
fix: i18n - 获取多语言配置
Browse files Browse the repository at this point in the history
  • Loading branch information
wangfupeng1988 committed Feb 21, 2022
1 parent ac89ac6 commit 9f81597
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/core/src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

import i18next from 'i18next'

// i18n nameSpace
const NS = 'translation'

i18next.init({
lng: 'zh-CN',
// debug: true,
Expand All @@ -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)
}

/**
Expand All @@ -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)
}

/**
* 翻译
*/
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export {
Toolbar,
i18nChangeLanguage,
i18nAddResources,
i18nGetResources,
t,
} from '@wangeditor/core'

Expand Down

0 comments on commit 9f81597

Please sign in to comment.