chore: abstract resources configure

This commit is contained in:
elvis liao 2024-09-27 16:31:24 +08:00
parent fcc0dd93fd
commit 1e2d8fa027
2 changed files with 19 additions and 13 deletions

View File

@ -2,24 +2,13 @@ import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import zh from './locales/zh.json'
import en from './locales/en.json'
import resources from './locales'
i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources: {
zh: {
name: '简体中文',
translation: zh
},
en: {
name: 'English',
translation: en
}
},
resources,
fallbackLng: 'zh',
debug: true,
interpolation: {

View File

@ -0,0 +1,17 @@
import { Resource } from 'i18next'
import zh from './zh.json'
import en from './en.json'
const resources: Resource = {
zh: {
name: '简体中文',
translation: zh
},
en: {
name: 'English',
translation: en
}
}
export default resources;