I am developing an app with Intel XDK and Cordova.
At the beginning of the code, I use these lines to get the preferred language from the device and store it into a variable named "lang":
navigator.globalization.getPreferredLanguage(
function (language) {
lang = language.value;
},
function () {alert('Err');}
);
Then I have some lines of code where I need this variable "lang" and its value, but for some reason, this function is being executed at the end, so during all the code execution lang is equal to null.
Is there any way to make sure this function is completed and lang has its value, before continuing?