How to get the browser language using JavaScript

Javascript

Javascript Problem Overview


> 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?

Javascript Solutions


Solution 1 - Javascript

Try this script to get your browser language

Cheers

Solution 2 - Javascript

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionghs.alshareefView Question on Stackoverflow
Solution 1 - JavascriptAlim Ul GiasView Answer on Stackoverflow
Solution 2 - JavascriptzzzzBovView Answer on Stackoverflow