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.