Skip to content

Commit

Permalink
feat:多语言设置结合本地存储
Browse files Browse the repository at this point in the history
  • Loading branch information
SunLxy committed May 8, 2022
1 parent 9c9b022 commit e2b8d85
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion website/src/language/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ i18n
.use(initReactI18next) // passes i18n down to react-i18next
.init({
resources,
lng: 'en', // language to use, more information here: https://www.i18next.com/overview/configuration-options#languages-namespaces-resources
lng: window.sessionStorage.getItem('loader-language') || 'en', // language to use, more information here: https://www.i18next.com/overview/configuration-options#languages-namespaces-resources
// you can use the i18n.changeLanguage function to change the language manually: https://www.i18next.com/overview/api#changelanguage
// if you're using a language detector, do not define the lng option
lowerCaseLng: true,
Expand All @@ -22,4 +22,8 @@ i18n
i18n.addResources('zh', 'translation', ZH);
i18n.addResources('en', 'translation', EN);

i18n.on('languageChanged', (lang) => {
window.sessionStorage.setItem('loader-language', lang);
});

export default i18n;

0 comments on commit e2b8d85

Please sign in to comment.