reactjs - 如何更改默认值 react-i18next(在本地存储中)
问题描述
我正在使用后端和语言检测器,但是:
在 localstorage 中写入I18nextLng的值为en-US,如何使默认值为I18nextLng的值为En
初始化和其他设置 - 默认文档
.init({
fallbackLng: 'en',
debug: true,
interpolation: {
escapeValue: false,
},
})
解决方案
我从来没有用过语言检测器,但是我设置默认语言的方式是设置lng键,并且有资源obj
const resources = {
en: { translation: {...} },
fr: { translation: {...} }
}
.init({
resources,
lng: 'fr' // this is the default language. Try to put this
fallbackLng: 'en',
debug: true,
interpolation: {
escapeValue: false,
},
})
推荐阅读
- here-api - 如何在 HERE API 中找到苏黎世机场以外的地方需要的 VENUE_ID?
- c - 使线性搜索更高效
- python - 如何获取标签编码器的映射
- c# - WPF 在整个窗口上捕获 DragOver,但只允许在特定区域放置
- c# - 如何返回异步方法的当前方法名称
- mysql - 通过使用 PASSPHRASE 启用 SSL 连接到 MySQL 时出错
- node.js - 为 HTTPS 设置超时的正确方法
- css - 将桌面图像渲染为移动 React JSX 的背景
- jsf - 使用 UIComponent 迁移 omnifaces 3.7.1 到 3.8.1 validateBean 后出错
- python - openpyxl 将工作表添加到工作簿