There may be times where you would want to detect the language of the users browser. I would normally use php to detect the users browser language. However, when this is not possible, it can also be done using the following javascript: thelocale = ‘en-GB’; // set default locale if ( navigator ) { if [...]
There is a very simple method to detect what language the users web browser is using. The following code: //session variable ensures it’s available //throughout current session $_SESSION['lang'] = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); echo $_SESSION['lang']; Will give you the correct two letter ISO code for the language the browser is using.
The ISO language code can be used to declare the language of a Web page (or a portion of a Web page) or identify the default browser language. Language ISO Code Abkhazian ab Afar aa Afrikaans af Albanian sq Amharic am Arabic ar Aragonese an Armenian hy Assamese as Aymara ay Azerbaijani az Bashkir ba [...]