Re: [PhoneGap] Phonegap javascript globalization detect languages and redirect to .html files

692 views
Skip to first unread message

Simon MacDonald

unread,
May 23, 2013, 8:03:09 PM5/23/13
to phonegap
I've been using "navigator.globalization.getLocaleName()" to find out what the current locale is of the Android phone.




On Tue, May 21, 2013 at 8:26 AM, fwefewef fewfwfew <nervtm...@gmail.com> wrote:

i know this was a topic before but i can´t find a proper solution for it.

I want to detect the language on the devices with phonegap, so i can redirect the user to the right indexLanguageX.html document.

I´ve got this code from the phonegap documentation:



function checkLanguage() {
  navigator.globalization.getPreferredLanguage(
    function (language) {alert('language: ' + language.value + '\n');},
    function () {alert('Error getting language\n');}
  );
}


This should check the preferred language and alert it, right? But it doesn´t work on my android device.. I also tried it with the phonegap alert version, doesn´t work either.

Can somebody tell me how i can get this to work?

After i get the alert, i still need to do the redirect. I thought this would work with something like:

function (language) {if (language.value=us_en) {  
   window.locaton="indexLanguageX.html"}},


--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com
---
You received this message because you are subscribed to the Google Groups "phonegap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Kerri Shotts

unread,
May 24, 2013, 2:36:35 PM5/24/13
to phon...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages