-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
【Task 1】Refactor the existing multiple languages feature by adopting …
…a third i18n library (#826) * refactor i18n options * refactor i18n in fork, star, pr, issue, perceptor * refactor i18n in ossgpt, header_label, developer * deleted some unnecessary files * optimize and simplify code * fix header labels issue
- Loading branch information
1 parent
d1a99cd
commit 902e28d
Showing
23 changed files
with
488 additions
and
963 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import i18n from 'i18next'; | ||
import { initReactI18next } from 'react-i18next'; | ||
import LanguageDetector from 'i18next-browser-languagedetector'; | ||
import Backend from 'i18next-http-backend'; | ||
import messages_en from '../locales/en/translation.json'; | ||
import messages_zh_CN from '../locales/zh_CN/translation.json'; | ||
|
||
const language_resources = { | ||
zh_CN: { | ||
translation: messages_zh_CN, | ||
}, | ||
en: { | ||
translation: messages_en, | ||
}, | ||
}; | ||
|
||
i18n | ||
// detect user language | ||
// learn more: https://github.com/i18next/i18next-browser-languageDetector | ||
.use(Backend) | ||
.use(LanguageDetector) | ||
// pass the i18n instance to react-i18next. | ||
.use(initReactI18next) | ||
// init i18next | ||
// for all options read: https://www.i18next.com/overview/configuration-options | ||
.init({ | ||
debug: false, | ||
fallbackLng: 'en', | ||
interpolation: { | ||
escapeValue: false, // not needed for react as it escapes by default | ||
skipOnVariables: false, | ||
}, | ||
resources: language_resources, | ||
}); | ||
|
||
export default i18n; |
Oops, something went wrong.