![](/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.