mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-16 16:13:56 +00:00
feat: refactor i18n setup to use local translation files and remove backend dependency
This commit is contained in:
@@ -7,7 +7,6 @@
|
|||||||
"history": "^5.3.0",
|
"history": "^5.3.0",
|
||||||
"i18next": "^24.2.2",
|
"i18next": "^24.2.2",
|
||||||
"i18next-browser-languagedetector": "^8.0.2",
|
"i18next-browser-languagedetector": "^8.0.2",
|
||||||
"i18next-http-backend": "^3.0.2",
|
|
||||||
"marked": "^4.1.1",
|
"marked": "^4.1.1",
|
||||||
"moment": "^2.30.1",
|
"moment": "^2.30.1",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import i18n from 'i18next';
|
import i18n from 'i18next';
|
||||||
import { initReactI18next } from 'react-i18next';
|
import {initReactI18next} from 'react-i18next';
|
||||||
import Backend from 'i18next-http-backend';
|
|
||||||
import LanguageDetector from 'i18next-browser-languagedetector';
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
||||||
|
import zhTranslation from './locales/zh/translation.json';
|
||||||
|
import enTranslation from './locales/en/translation.json';
|
||||||
|
|
||||||
i18n
|
i18n
|
||||||
.use(Backend)
|
|
||||||
.use(LanguageDetector)
|
.use(LanguageDetector)
|
||||||
.use(initReactI18next)
|
.use(initReactI18next)
|
||||||
.init({
|
.init({
|
||||||
@@ -15,9 +15,14 @@ i18n
|
|||||||
escapeValue: false,
|
escapeValue: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
backend: {
|
resources: {
|
||||||
loadPath: '/locales/{{lng}}/{{ns}}.json',
|
zh: {
|
||||||
},
|
translation: zhTranslation
|
||||||
|
},
|
||||||
|
en: {
|
||||||
|
translation: enTranslation
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default i18n;
|
export default i18n;
|
||||||
|
Reference in New Issue
Block a user