4umi.com/web/html/languagecodes

Browser language codes

Useful HTML

With every page request, a browser sends some information about itself to the server from which it requests something. That includes information about the user's language settings. Websites that have content in multiple languages can redirect or send back different pages depending on the language settings found.

Your preference

Users can change their settings through the preferences settings of their browser. In Internet Explorer, this can be found via ToolsInternet Options…. Under the ‘General’ tab a button labeled ‘Languages’ pops up the Language Preference dialog. This button can do the same:

The code follows:

<input type="button" value="Show Language Dialog"
 onclick="if( window.external ) {
  window.external.ShowBrowserUI( 'LanguageDialog', null );
 } else {
  window.alert( 'Sorry, this feature is not available in this browser.' );
 }"
/>

Your browser

Serverside detection in PHP

In PHP, the setting is made available as an element in the global $_SERVER array:

Clientside detection in Javascript

In Javascript, the navigator property of the window object may have some of the following properties set, depending on the browser. Typically, Netscape and derivations put the default browser language in the language property, while IE has the OS language in systemLanguage and the user preference for the browser in userLanguage.

Languages

The values found may be one or more of the following, with the corresponding meaning: