mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 12:37:20 +08:00
load on server
This commit is contained in:
parent
731d15888d
commit
fcd25d3d45
@ -11,18 +11,16 @@ import { i18n } from '.'
|
|||||||
|
|
||||||
// https://locize.com/blog/next-13-app-dir-i18n/
|
// https://locize.com/blog/next-13-app-dir-i18n/
|
||||||
const initI18next = async (lng: Locale, ns: Namespace) => {
|
const initI18next = async (lng: Locale, ns: Namespace) => {
|
||||||
const camelNs = camelCase(ns) as KeyPrefix
|
|
||||||
const i18nInstance = createInstance()
|
const i18nInstance = createInstance()
|
||||||
await i18nInstance
|
await i18nInstance
|
||||||
.use(initReactI18next)
|
.use(initReactI18next)
|
||||||
.use(resourcesToBackend((language: Locale, namespace: string) => {
|
.use(resourcesToBackend((language: Locale, namespace: string) => {
|
||||||
const kebabNs = namespace.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`)
|
return import(`../i18n/${language}/${namespace}.json`)
|
||||||
return import(`../i18n/${language}/${kebabNs}.json`)
|
|
||||||
}))
|
}))
|
||||||
.init({
|
.init({
|
||||||
lng: lng === 'zh-Hans' ? 'zh-Hans' : lng,
|
lng: lng === 'zh-Hans' ? 'zh-Hans' : lng,
|
||||||
ns: camelNs,
|
ns,
|
||||||
defaultNS: camelNs,
|
defaultNS: ns,
|
||||||
fallbackLng: 'en-US',
|
fallbackLng: 'en-US',
|
||||||
})
|
})
|
||||||
return i18nInstance
|
return i18nInstance
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user