Tag Archive

Detect Locale with javascript

Published on 31 Oct 2011 By admin

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 [...]

PHP Language Detection

Published on 15 Oct 2011 By admin

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.

ISO Language codes

Published on 15 Oct 2011 By admin

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 [...]