Save way to detect Browser Language

M

Matthias S.

Hi all!

What is the best way to detect the Browsers preferred language
(HTTP_ACCEPT_LANGUAGE)? Having Trace enabled I used a couple of
different Browser and figured, that they all send a different format for
this information. Is there a sort-of failsafe approach to it?

Thanks in advance!
 
Joined
Dec 28, 2007
Messages
1
Reaction score
0
navigator.browserLanguage

Hi Everyone,

I'm dharyl from Philippines, I had a problem in knowing the user's browser Language. I was asked to have an alert pop up when the user of the site is using other language than "en-us".
I had this code below just to test what language setting should the page read from the user.

Code: ( javascript )
<script language="JavaScript">
var a = navigator.browserLanguage;
var b = navigator.userLanguage;
var c = navigator.systemLanguage;
alert("browser language");
alert(a);
alert("user language");
alert(b);
alert("system language");
alert(c);
</script>


Code: ( text )
navigator.browserLanguage --> en-us
navigator.systemLanguage --> en-us
navigator.userLanguage --> en-us


when I change my browser language from Tools>InternetOptions>General>Languages
results are the same:

Code: ( text )
navigator.browserLanguage --> en-us
navigator.systemLanguage --> en-us
navigator.userLanguage --> en-us


when I change my browser language from
Start>ControlPanel>RegionalandLanguageOptions>Regional Options tab
the value of userLanguage changes just as what I set:

Code: ( text )
navigator.browserLanguage --> en-us
navigator.systemLanguage --> en-us
navigator.userLanguage --> Ja


That means navigator.userLanguage is for this one
Start>ControlPanel>RegionalandLanguageOptions>Regional Options tab

Now my point is how would I get the value of language setting from this one?
Tools>InternetOptions>General>Languages

Because I guess that's what I need for my task to be done.
Hope you guys can help me on this.


Thanks in advance,
dha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top