Skip to content

Commit

Permalink
feat: default language will be given according to the browse setting …
Browse files Browse the repository at this point in the history
…and also can be configured infiniflow#801
  • Loading branch information
cike8899 committed May 17, 2024
1 parent 4ca176b commit 24fdfd4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
9 changes: 9 additions & 0 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"dayjs": "^1.11.10",
"eventsource-parser": "^1.1.2",
"i18next": "^23.7.16",
"i18next-browser-languagedetector": "^8.0.0",
"js-base64": "^3.7.5",
"jsencrypt": "^3.3.2",
"lodash": "^4.17.21",
Expand Down
23 changes: 15 additions & 8 deletions web/src/locales/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import i18n from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';

import translation_en from './en';
Expand All @@ -11,13 +12,19 @@ const resources = {
'zh-TRADITIONAL': translation_zh_traditional,
};

i18n.use(initReactI18next).init({
resources,
lng: 'en',
fallbackLng: 'en',
interpolation: {
escapeValue: false,
},
});
i18n
.use(initReactI18next)
.use(LanguageDetector)
.init({
detection: {
lookupLocalStorage: 'lng',
},
supportedLngs: ['en', 'zh', 'zh-TRADITIONAL'],
resources,
fallbackLng: 'en',
interpolation: {
escapeValue: false,
},
});

export default i18n;

0 comments on commit 24fdfd4

Please sign in to comment.