Select language based on OS
here's the situation..
I'm trying to find a way to read the OS language so that I can set the language on my webpage. I've searched the web for such method but haven't been able to find one. Is there anyone who can tell how to do this.
Thanks in advance!
The following code can be used to detect OS
var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
document.write('Your OS: '+OSName);
thanks for your reply on my post. You don't happen to know how to retrieve the language used on the OS...? Because that's what I need to find out.
You can get the browser language through this:
I don't know how to get it from the OS though, sorry.
var lang = navigator.browserLanguage;
alert("Browser language: "+lang)
thanks you very much!
I'll try it and let you guys know when it works. Probably not within a few minutes, but a.s.a.p.
in FF3, navigator.language == "en-US" for me, but navigator.browserLanguage is empty...
Hi rnd me,
Originally Posted by rnd me
interesting fact you've got there. I've tried both options and this is my result.
In case of FF3 I'd have to use your option
In case of IE I'd have to use Quidam's version
So all I have to do is combine those two options with kmatheeswar's input. Modify it so that it gets the browser type and voila.
Retrieve the browser type en based on that result retrieve the language
Last edited by Menno; 08-20-2009 at 03:19 AM.
Originally Posted by Quidam
I've found a way to retrieve the OS language.
I've chosen to go for the browser lang option but for those who read this thread...
Returns the default language of the operating system (ie: en-us). IE only.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)