如何解决反应内部化i18n,基于浏览器检测加载json文件
我正在尝试仅加载特定的浏览器检测语言json文件。但是,我可以在浏览器中看到所有其他语言的json文件正在导入。预先感谢。
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;`
谢谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。