add language detector lib
This commit is contained in:
1 parent
401eab5062
commit
fe827b5b2a
2 files changed
+5
-2
No files matched your search
@@ -17,9 +17,9 @@
|
|||||||
"prepublishOnly": "npm run build"
|
"prepublishOnly": "npm run build"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
"i18next": "^15.1.3",
|
||||||
"react": "^16.0.0",
|
"react": "^16.0.0",
|
||||||
"react-dom": "^16.0.0",
|
"react-dom": "^16.0.0",
|
||||||
"i18next": "^15.1.3",
|
|
||||||
"react-i18next": "^10.11.0"
|
"react-i18next": "^10.11.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -51,7 +51,8 @@
|
|||||||
"rollup-plugin-node-resolve": "^4.0.0",
|
"rollup-plugin-node-resolve": "^4.0.0",
|
||||||
"rollup-plugin-peer-deps-external": "^2.2.0",
|
"rollup-plugin-peer-deps-external": "^2.2.0",
|
||||||
"rollup-plugin-postcss": "^2.0.3",
|
"rollup-plugin-postcss": "^2.0.3",
|
||||||
"rollup-plugin-url": "^2.1.0"
|
"rollup-plugin-url": "^2.1.0",
|
||||||
|
"i18next-browser-languagedetector": "^3.0.1"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import i18n from 'i18next';
|
import i18n from 'i18next';
|
||||||
import { initReactI18next } from 'react-i18next';
|
import { initReactI18next } from 'react-i18next';
|
||||||
|
import LngDetector from 'i18next-browser-languagedetector';
|
||||||
|
|
||||||
const currentLanguage = process.env.REACT_APP_LANG || 'en-US';
|
const currentLanguage = process.env.REACT_APP_LANG || 'en-US';
|
||||||
const debugMode = !!(
|
const debugMode = !!(
|
||||||
@@ -63,6 +64,7 @@ function addLocales(context) {
|
|||||||
let translate;
|
let translate;
|
||||||
|
|
||||||
i18n
|
i18n
|
||||||
|
.use(LngDetector)
|
||||||
.use(initReactI18next)
|
.use(initReactI18next)
|
||||||
.init({
|
.init({
|
||||||
resources: getLocales(),
|
resources: getLocales(),
|
||||||
|
|||||||
Reference in new issue
Block a user