How to find out what language a visitor's browser is using
If you want to get to know your website's visitors a bit better, you may want to find out what language's their browsers are in. Alternatively you may even want to adjust the language that your website is displayed in based on the browser language.
To find out a web browser's language, all that you need to do is use the following line of code. Here an example of the language being loaded into a variable:
var browserLingo = navigator.browserLanguage;
And there you have it. That is all there is to it. Below we have an extended example with the language being loaded into a span tag:
<title>How to find out what language a visitor's browser is using</title>
var spanLanguage = document.getElementById("language");
spanLanguage.innerHTML = navigator.browserLanguage;