Search code examples
ioscordovaglobalization

Phonegap/Cordova: Globalization not working on iOS


Hey i´ve got this code to check for languages and redirect to the right .html file. It works perfectly in Android, but isn´t working in iOS. Is something different in iOS or what is wrong with the code?

Pleas help me!

The code:

 document.addEventListener("deviceready", onDeviceReady, false);

  // Cordova is ready
  //
  function onDeviceReady() {
   navigator.globalization.getPreferredLanguage(
   function (language)
   {
       if(language.value == "English")
       {
           window.location.replace("fadeE.html");
       }
       else if(language.value == "Deutsch")
       {
           window.location.replace("fade.html");
       }
        else if(language.value == "Nederlands")
       {
           window.location.replace("fadeN.html");
       }
       else 
       {
           window.location.replace("fadeE.html");
       }
   },
   function ()
   {
       alert('Error getting language\n');
   }
 );

}

Solution

  • for all the others, wondering why it isn´t working like that:

    the language.value is different in iOS:

    Deutsch = de
    English = en
    Niederlands = nl