Reactjs React Internalization i18n,基于浏览器检测加载json文件
我试图只加载特定的浏览器检测语言json文件。但是,我可以在浏览器中看到正在导入所有其他语言的json文件。提前谢谢Reactjs React Internalization i18n,基于浏览器检测加载json文件,reactjs,browser,localization,detection,Reactjs,Browser,Localization,Detection,我试图只加载特定的浏览器检测语言json文件。但是,我可以在浏览器中看到正在导入所有其他语言的json文件。提前谢谢 import i18n from "i18next"; import detector from "i18next-browser-languagedetector"; import backend from "i18next-xhr-backend"; import { reactI18nextModule } fro
import i18n from "i18next";
import detector from "i18next-browser-languagedetector";
import backend from "i18next-xhr-backend";
import { reactI18nextModule } from "react-i18next";
// translations are already at
// '../public/locales/en/translation.json'
// which is the default for the xhr backend to load from
i18n
.use(detector)
.use(backend)
.use(reactI18nextModule) // passes i18n down to react-i18next
.init({
//lng: "en",
fallbackLng: "en", // use en if detected lng is not available
keySeparator: false, // we do not use keys in form messages.welcome
interpolation: {
escapeValue: false // react already safes from xss
}
});
export default i18n;`
提前谢谢
import i18n from "i18next";
import detector from "i18next-browser-languagedetector";
import backend from "i18next-xhr-backend";
import { reactI18nextModule } from "react-i18next";
// translations are already at
// '../public/locales/en/translation.json'
// which is the default for the xhr backend to load from
i18n
.use(detector)
.use(backend)
.use(reactI18nextModule) // passes i18n down to react-i18next
.init({
//lng: "en",
fallbackLng: "en", // use en if detected lng is not available
keySeparator: false, // we do not use keys in form messages.welcome
interpolation: {
escapeValue: false // react already safes from xss
}
});
export default i18n;`