Skip to content

Commit e2b8d85

Browse files
committed
feat:多语言设置结合本地存储
1 parent 9c9b022 commit e2b8d85

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

website/src/language/i18n.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ i18n
1313
.use(initReactI18next) // passes i18n down to react-i18next
1414
.init({
1515
resources,
16-
lng: 'en', // language to use, more information here: https://www.i18next.com/overview/configuration-options#languages-namespaces-resources
16+
lng: window.sessionStorage.getItem('loader-language') || 'en', // language to use, more information here: https://www.i18next.com/overview/configuration-options#languages-namespaces-resources
1717
// you can use the i18n.changeLanguage function to change the language manually: https://www.i18next.com/overview/api#changelanguage
1818
// if you're using a language detector, do not define the lng option
1919
lowerCaseLng: true,
@@ -22,4 +22,8 @@ i18n
2222
i18n.addResources('zh', 'translation', ZH);
2323
i18n.addResources('en', 'translation', EN);
2424

25+
i18n.on('languageChanged', (lang) => {
26+
window.sessionStorage.setItem('loader-language', lang);
27+
});
28+
2529
export default i18n;

0 commit comments

Comments
 (0)