![](/img/trans.png)
[英]Cordova Build Windows Error - Missing Microsoft.WinJS.2.0
[英]Localization in Cordova+WinJS application
我尝试使用“用于Apache Cordova的WinJS导航模板”构建示例WinJS应用程序( https://code.msdn.microsoft.com/windowsapps/WinJS-Navigation-Template-50112ea9/view/SourceCode )。
在本应用程序中添加本地化的正确方法是什么? WinJS方式的标准 - 使用strings / en-US / resources.resjson - 不起作用。
WinJS.Resources.processAll()
似乎在Cordova应用程序中不起作用的原因是因为WinRT运行时在浏览器托管的应用程序中不可用 。
这不是直接写在文档中,而是隐含在应用程序资源和本地化示例中 :
// WinRT is not available in the web compartment, so we must load strings ourselves
// File based resources can be used to load the correct strings
WinJS.xhr({ url: '/strings/resources.json' }).done(function (response) {
strings = JSON.parse(response.responseText);
WinJS.Resources.processAll();
showMessage();
});
我认为您缺少这些区域设置文件资源的处理。 它应该在就绪处理程序的pages/home/home.js
上。 像这样
ready: function (element, options) {
WinJS.Resources.processAll();
.
.
.
}
这将使用本地化并将其替换为使用它们的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.