Fix i18next browser language detection
for 736
This commit is contained in:
parent
9a1d325863
commit
0c30589487
1 changed files with 3 additions and 10 deletions
|
@ -3,11 +3,6 @@ import LanguageDetector from 'i18next-browser-languagedetector';
|
||||||
import HttpBackend from 'i18next-http-backend';
|
import HttpBackend from 'i18next-http-backend';
|
||||||
import { initReactI18next } from 'react-i18next';
|
import { initReactI18next } from 'react-i18next';
|
||||||
|
|
||||||
const allLocales = {
|
|
||||||
zh: import('src/i18n/zh'),
|
|
||||||
en: import('src/i18n/en'),
|
|
||||||
};
|
|
||||||
|
|
||||||
type BackendRequestCallback = (err: null, result: { status: number; data: any }) => void;
|
type BackendRequestCallback = (err: null, result: { status: number; data: any }) => void;
|
||||||
|
|
||||||
i18next
|
i18next
|
||||||
|
@ -16,10 +11,9 @@ i18next
|
||||||
.use(LanguageDetector)
|
.use(LanguageDetector)
|
||||||
.init({
|
.init({
|
||||||
debug: process.env.NODE_ENV === 'development',
|
debug: process.env.NODE_ENV === 'development',
|
||||||
// resources,
|
|
||||||
backend: {
|
backend: {
|
||||||
loadPath: '/__{{lng}}/{{ns}}.json',
|
loadPath: '/__{{lng}}/{{ns}}.json',
|
||||||
request: function (
|
request: function(
|
||||||
_options: any,
|
_options: any,
|
||||||
url: string,
|
url: string,
|
||||||
_payload: any,
|
_payload: any,
|
||||||
|
@ -30,11 +24,11 @@ i18next
|
||||||
switch (url) {
|
switch (url) {
|
||||||
case '/__zh/translation.json':
|
case '/__zh/translation.json':
|
||||||
case '/__zh-CN/translation.json':
|
case '/__zh-CN/translation.json':
|
||||||
p = allLocales.zh;
|
p = import('src/i18n/zh');
|
||||||
break;
|
break;
|
||||||
case '/__en/translation.json':
|
case '/__en/translation.json':
|
||||||
default:
|
default:
|
||||||
p = allLocales.en;
|
p = import('src/i18n/en');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +39,6 @@ i18next
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
supportedLngs: ['en', 'zh'],
|
|
||||||
fallbackLng: 'en',
|
fallbackLng: 'en',
|
||||||
interpolation: {
|
interpolation: {
|
||||||
escapeValue: false,
|
escapeValue: false,
|
||||||
|
|
Loading…
Reference in a new issue