mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-28 11:53:24 +03:00
feat: init languageDetector
This commit is contained in:
parent
dc4a69593b
commit
d0da2a16c3
@ -19,6 +19,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"i18next": "^21.9.1",
|
||||
"i18next-browser-languagedetector": "^7.0.1",
|
||||
"prettier": "^2.7.1",
|
||||
"react-i18next": "^11.18.4"
|
||||
},
|
||||
|
@ -1,5 +1,6 @@
|
||||
import i18next, { Resource } from 'i18next';
|
||||
import { Trans, initReactI18next, useTranslation } from 'react-i18next';
|
||||
import detector from 'i18next-browser-languagedetector';
|
||||
import { LOCALES } from './resources/index.js';
|
||||
import type en_US from './resources/en.json';
|
||||
|
||||
@ -45,15 +46,18 @@ const language = standardizeLocale(
|
||||
);
|
||||
|
||||
const i18n = i18next.createInstance();
|
||||
i18n.use(initReactI18next).init({
|
||||
lng: language,
|
||||
fallbackLng,
|
||||
debug: false,
|
||||
resources,
|
||||
interpolation: {
|
||||
escapeValue: false, // not needed for react as it escapes by default
|
||||
},
|
||||
});
|
||||
i18n
|
||||
.use(detector)
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
lng: language,
|
||||
fallbackLng,
|
||||
debug: false,
|
||||
resources,
|
||||
interpolation: {
|
||||
escapeValue: false, // not needed for react as it escapes by default
|
||||
},
|
||||
});
|
||||
|
||||
i18n.on('languageChanged', () => {
|
||||
// localStorage.setItem(STORAGE_KEY, lng);
|
||||
|
@ -162,11 +162,13 @@ importers:
|
||||
specifiers:
|
||||
'@types/prettier': ^2.7.2
|
||||
i18next: ^21.9.1
|
||||
i18next-browser-languagedetector: ^7.0.1
|
||||
prettier: ^2.7.1
|
||||
react-i18next: ^11.18.4
|
||||
typescript: ^4.8.4
|
||||
dependencies:
|
||||
i18next: 21.10.0
|
||||
i18next-browser-languagedetector: 7.0.1
|
||||
prettier: 2.7.1
|
||||
react-i18next: 11.18.6_i18next@21.10.0
|
||||
devDependencies:
|
||||
@ -5610,6 +5612,12 @@ packages:
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/i18next-browser-languagedetector/7.0.1:
|
||||
resolution: {integrity: sha512-Pa5kFwaczXJAeHE56CHG2aWzFBMJNUNghf0Pm4SwSrEMps/PTKqW90EYWlIvhuYStf3Sn1K0vw+gH3+TLdkH1g==}
|
||||
dependencies:
|
||||
'@babel/runtime': 7.20.7
|
||||
dev: false
|
||||
|
||||
/i18next/21.10.0:
|
||||
resolution: {integrity: sha512-YeuIBmFsGjUfO3qBmMOc0rQaun4mIpGKET5WDwvu8lU7gvwpcariZLNtL0Fzj+zazcHUrlXHiptcFhBMFaxzfg==}
|
||||
dependencies:
|
||||
|
Loading…
Reference in New Issue
Block a user