Skip to content

Commit

Permalink
feat: refactor i18n setup to use local translation files and remove b…
Browse files Browse the repository at this point in the history
…ackend dependency
  • Loading branch information
songquanpeng committed Feb 2, 2025
1 parent c81ee68 commit ca334a5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
1 change: 0 additions & 1 deletion web/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 11 additions & 6 deletions web/default/src/i18n.js
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -15,9 +15,14 @@ i18n
escapeValue: false,
},

backend: {
loadPath: '/locales/{{lng}}/{{ns}}.json',
},
resources: {
zh: {
translation: zhTranslation
},
en: {
translation: enTranslation
}
}
});

export default i18n;
File renamed without changes.
File renamed without changes.

0 comments on commit ca334a5

Please sign in to comment.