Skip to content

Commit

Permalink
Default language will be given according to the browse setting and al…
Browse files Browse the repository at this point in the history
…so can be configured infiniflow#801 (infiniflow#823)

### What problem does this PR solve?

Default language will be given according to the browse setting and also
can be configured infiniflow#801
### Type of change


- [x] New Feature (non-breaking change which adds functionality)
  • Loading branch information
cike8899 committed May 17, 2024
1 parent a2a6a35 commit 9f0f5b4
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 9f0f5b4

Please sign in to comment.