JavaScript  -  Browser Language

Option 1.   Save this script in the <head> of your html document

<script type="text/javascript">
var navLang1 = navigator.language;
</script>

and use this script in the <body>

<script type="text/javascript">
<!--
document.write(""+navLang1+"");
//-->
</script>

Browser Language - Displays:

 

Option 2.   Save this script in your js folder

Save the following script as browserlang.js

<!--
var navLang2 = navigator.language;
document.write(""+navLang2+"");
// or
// document.write(""+navigator.language+"");
// without variable
//-->

and refer to it in the <body> of your html document

<script src="/js/browserlang.js" type="text/javascript"></script>

Browser Language - Displays:

 

Option 3.   Embed this script in the <body> of your html document

<script type="text/javascript">
<!--
var navLang3 = navigator.language;
document.write(""+navLang3+"");
// or
// document.write(""+navigator.language+"");
// without variable
//-->
</script>

Browser Language - Displays:

 

When your browser pulls a document from the web, it sends a request to the server where the information is stored. This is known as an HTTP request. With the request, the browser sends information about its language preference settings. These are preferences about the preferred language of pages, not the user interface of the browser. The part of the HTTP request that holds this language preference information is called the Accept-Language request-header. If the server can return alternate versions of a page or resource in more than one language, the Accept-Language information can be used to retrieve the page in your preferred language, if it is available, through a process known as HTTP content negotiation. If there is only one version of a page on the server, that version will be retrieved. If the language you request is not available, the server should be set up to return a default language choice. Mainstream browsers allow you to modify the language preferences expressed by your browser in the HTTP request. The value itself should conform to BCP47, Tags for the Identification of Languages. It is typically a two or three-letter language code, e.g., fr for French, followed by optional subcodes representing such things as country, e.g., fr-CA represents French as used in Canada. In many cases the initial browser setting will meet your needs. For example, if you have a Japanese version of a browser, the browser typically assumes that you prefer pages in Japanese, and sends this information to the server. Sometimes a server may determine which language to send to you in a way that doesn't rely on the Accept-Language information. For example, Google tends to use IP information to determine the language you will receive.