feat: refactor i18n setup to use local translation files and remove backend dependency

This commit is contained in:
JustSong 2025-02-02 18:40:04 +08:00
parent c81ee68dd0
commit ca334a5502
4 changed files with 11 additions and 7 deletions

View File

@ -7,7 +7,6 @@
"history": "^5.3.0",
"i18next": "^24.2.2",
"i18next-browser-languagedetector": "^8.0.2",
"i18next-http-backend": "^3.0.2",
"marked": "^4.1.1",
"moment": "^2.30.1",
"react": "^18.2.0",

View File

@ -1,10 +1,10 @@
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import Backend from 'i18next-http-backend';
import {initReactI18next} from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import zhTranslation from './locales/zh/translation.json';
import enTranslation from './locales/en/translation.json';
i18n
.use(Backend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
@ -15,9 +15,14 @@ i18n
escapeValue: false,
},
backend: {
loadPath: '/locales/{{lng}}/{{ns}}.json',
},
resources: {
zh: {
translation: zhTranslation
},
en: {
translation: enTranslation
}
}
});
export default i18n;