How to get the browser language using JavaScript [duplicate]

Possible Duplicate:
JavaScript for detecting browser language preference

I want to detect the language of the browser that is entering my site, if it's En or Fr. So I can redirect to the En page or the other page.

Also, can I detect mobile language?



Try this script to get your browser language

<script type="text/javascript">
var userLang = navigator.language || navigator.userLanguage; 
alert ("The language is: " + userLang);



The "JavaScript" way:

var lang = navigator.language || navigator.userLanguage; //no ?s necessary

Really you should be doing language detection on the server, but if it's absolutely necessary to know/use via JavaScript, it can be gotten.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.