ios - i18next 不能在 Cordova iOS 6.1.0 上翻译
问题描述
我已经在 iOS 和 Android 上使用了多年的 v1.10.x,但是随着新迁移到 wkwebview i18next(包括 1.11.2),它只返回了密钥。我很好奇是否有人在 Cordova iOS 6.1.0、Cordova 9.0.0 中成功使用 i18next,以及是否有人能发现我的错误。
[编辑] 调试时,我收到此错误,但它有点无用
2020-07-15 11:08:29.649177-0700 myapp[15438:5134539] error when loading /src/locales/en/translation.json
[/编辑]
这是我的 i18next 初始化代码,min 包由 index.html 加载。我将资源对象添加到 init 选项中,以查看我的 translation.json 文件是否存在问题,但显式资源也没有翻译。此初始化在 Cordova Android 9.0 上运行良好。
/* ******************* internationalization and go **************** */
// initialize i18n, launch react in the callback so we're able to localize
i18n.init(
{
fallbackLng: "en",
debug: true,
resources: {
en: {
translation: {
"clf_js_Username": "Who ARE you?"
}
}
}
},
function(err, t) {
if (typeof err !== "undefined") {
console.log("LH.iLE - initialization returned error >" + err + "<");
}
setTimeout(() => {
console.log(
"********** i.i18init is complete - starting react **********"
);
// setup the action groups for 'special' notifications
// addKatzerActionGroups();
//************** launch React+Redux **********
(blah blah blah——超时是一个幻数 1000ms 以允许 i18n 初始化) );
解决方案
安装这个插件(cordova-ios 6+)
cordova plugin add https://github.com/globules-io/cordova-plugin-ios-xhr
然后设置
<preference name="AllowUntrustedCerts" value="true" />
<preference name="InterceptRemoteRequests" value="all" />
<preference name="allowFileAccessFromFileURLs" value="true" />
<preference name="allowUniversalAccessFromFileURLs" value="true" />
推荐阅读
- flutter - 如何在颤动中使用图像选择图像创建表单?
- mysql - 根据 WHERE 条件更新一行,否则执行 INSERT
- javascript - path.join() 添加制表符和换行符 (node.js)
- python-3.x - 如何显示两个 Pandas 数据框之间的逻辑关系?
- python - 如何解决 Keras 上的输入格式问题
- java - 有什么方法可以统计这个玩家选择“1”的次数
- text - 在美丽的汤中选择带有一些指定文本的标签
- javascript - 错误:未捕获 [TypeError:无法读取未定义 Jest 反应测试的属性“x”
- python - Pandas - 根据条件生成列
- flutter - 有什么方法可以在颤动中删除条形图中的这条线