Reputation: 1990
I'm try to build sample WinJS application with "WinJS Navigation Template for Apache Cordova" ( https://code.msdn.microsoft.com/windowsapps/WinJS-Navigation-Template-50112ea9/view/SourceCode ).
What is a right way to add localization to this application? Standard for WinJS way - use strings/en-US/resources.resjson - doesn't work.
Upvotes: 1
Views: 538
Reputation: 424
The reason WinJS.Resources.processAll()
does not seem to work in a Cordova app is because the WinRT runtime is not available in browser-hosted applications.
This is not directly written in the documentation, but is implied in the Application resources and localization sample:
// 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();
});
Upvotes: 2
Reputation: 7405
I think you are missing the processing for those locale file resources. It should be on the pages/home/home.js
on ready handler. Like this
ready: function (element, options) {
WinJS.Resources.processAll();
.
.
.
}
This makes use of the localizations and replaces those to places where they are used.
Upvotes: 1