I’m trying to use cordova globalization plugin via ngCordova. I’ve already followed all steps in ngcordova.com/docs about installing and seting up the ngCordova even followed the common issues guide to double check.
Testing to see if it works I made a call to $cordovaGlobalization.getLocaleName() method and even wrapping it up in a $ionicPlatform.ready(function() the console prompts navigator.globalization is undefined and a plethora of errors.
$ionicPlatform.ready(function() {
$cordovaGlobalization.getLocaleName().then(
function (result) {
$scope.locale = result.value;
},
function (error) {
$scope.locale = err.message;
});
});
I’m pretty stuck here and haven’t found a solution to this, hope you guys can help me.
EDIT:
Reading cordova globalization docs I’ve noticed somehow the plugin installation is not working properly because they say:
This plugin defines global navigator.globalization object.
I have the same problem. I amb writting an application and I want to know what Language is being used by the mobile user to offer internationalization translations. Any idea about it ?
Maybe having your code inside inside $ionicPlatform.ready does not make sure that Cordova is ready,
just that IONIC UI is.
Try putting your code inside :
document.addEventListener(“deviceready”, function () {
$cordovaPlugin.someFunction().then(success, error);
}, false);
Also, you can see what is happening by using Chrome DevTools. You will be able to see if navigator is still null (what I suspect)
Hope this helps.
I struggled a bit with this plugin,until I tried to inspect the app with Chrome (app is android), and it actually worked.
For what I now understand, it seems the plugin only does its work on the actual device, so I’ll need to monitor the device itself. ngCordovas plugins It will always fail while developing, as they are targeting the device’s capabilities, not the browser’s.