when geolocation becomes a problem

Following the excellent article in smashingmagazine about geolocation, in their comments I found these interesting ideas:

comments from smashingmagazine

In a world where a lot of people travel and bring their laptops or iPhones, it is nonsense that a website turns to a language based on the IP location. I do not want to mean that geolocation should not be used – it is great almost for every use, but not for setting up the default language.

Your user experience is not everyone’s experience

When you go to Barcelona, you guess everyone (can) speak spanish. But almost all local people speak a different language called catalan, and most important, there are thousands of tourists who rather prefer english or chinese.

Imagine you want to travel to Laos, and you arrive to Vientiane. Quickly you go to a local cybercafe, or you just switch your new iPad on, and it connects to the wifi of the guest hostel. And it turns out that every website is in laosian. Isn’t that cool? You’re lost and you can only guess how to change website languages with tiny coloured flags (if any at all!)

Default website language must not be based on IP geolocation

If you are programming a multilingual site, why should you oblige anyone to speak the language where the computer is? Ok, it is a nice feature, you can read the IP and geolocate it. And what is the point if you ruin a user’s visit who cannot understand a word?

Do not choose a default language based on the IP geolocation. I mean: DO NOT CHOOSE A DEFAULT LANGUAGE BASED ON THE IP GEOLOCATION. You will gain an angry user otherwise. And bad experiences when travelling are reminded forever. You will not remember this post unless it will happen to you at least once.

Some exceptions

Retailers which redirect to a specific, local page, like Dell. If they have only one language for each local website, and they cannot sell USA computers in France, there’s no point on showing the USA website to an american user who travels to France. (But still, it would be a good idea to change the language to english, yet showing the French site).

TravelAdvisor choose a different approach: they ask visitors when they arrive for the first time. Afterwards, a cookie is set and the question will not be asked again.

screen capture of tripadvisor.com, showing the default language option

CNN does it the same way:

Screencapture of cnn.com - with the default language selection tool

Ebay used to do the same, not anymore.

The bad way: choosing a language based on IP geolocation

I am not showing how to get the IP (the mentioned article does it very well) and change the language based on that. But I will let you know some sites which are worth to know.

http://www.andorra.ad/
is the official touristic website for the small country between Spain and France; when in France, it redirects to


http://www.andorra.ad/fr-FR/Pages/default.aspx

and when in Spain it redirects to


http://www.andorra.ad/es-ES/Paginas/default.aspx

Andorra.ad example of bad language selection through geolocation

The good way: choosing a language based on browser’s language

Google was a perfect example of showing both search and results pages in a language according to the location of the IP. It is not anymore; it follows the default browser’s language, defined by the user. If your language is catalan, then google.com will look like:

Screencapture of Google.com showing catalan as default language

And since I am in France, it offers to switch to French (though it would be better to offer it at the top, where the user expects it). Perfect job.

NBA does it with a different, cheaper approach. It does not change the language (always English), but based on geolocation, it offers to change it. When visited from France, have a look at the left (French) flag:

Screencapture of nba.com, with the french flag on the left side

Two guidelines

The US government, probably during Obama’s administration, started to offer all its information in two languages, adding Spanish to the default English. And it published some recommendations about it in the Webcontent.gov site:

Screencapture of webcontent.gov showing best practices for multilingual websites

Let me quote it:

Online communications must address the language preferences of users.

Being on a place is not a language preference, it is geographic data which could be temporary.

Jakob Nielsen, the usability guru, said it as well:

In many ways, the ideal international user interface is one that is available in the user’s preferred language.

How to get the language preferred by the visitor

For getting the language set on the visitor browser, you can use this php script:

<?php
/*
 * detect the first preferred language of visitor
 *
 * @copyright Fulgencio Sanmartin <f@geometrus.com>
 * @license http://creativecommons.org/licenses/by-nc-sa/3.0/
 *
 * explode the header Accept-Language and get the value
 * @param string $defaultLang, default en
 *
*/
function getBrowserLanguage( $defaultLang = 'en' )
{
  $langList = explode( ',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
    /* Actually, the language set is usually a list of languages; let's take the first, as they can be ordered */
  if( empty( $curLang ) )
  {
     $newLang = $defaultLang;
  }
  else
  {
    $curLang = explode( ';', $curLang );
    if( isArray( $curLang ) )
      $newLang = $curLang[ 0 ];
    else
      $newLang = $curLang;
  }
  return $newLang;
}
?>

and do the call like this:

  $lang = getBrowserLanguage();
  switch( substr( $lang, 0, 2 ) )
  {
    case 'es', 'fr': $newHome = $lang;
                     break;
    case 'ca': $newHome = 'es';
                     break;
    default: $newHome = 'en';
  }
  header( 'location: /' . $newHome );

placed on a home page, it would redirect to the right language subdirectory: ‘es’, ‘fr’ or ‘en’ (default).

A more complete script can be found here, with the complete list of languages.

How to set the language preferred by the visitor

Just in case, here you can find a link which explains how to set the default language on your browser. By the way, this w3c page changes its default language depending on the one selected on your browser:

http://www.w3.org/International/questions/qa-lang-priorities#answer

Screencapture on w3c, on how to change the browser default language

share this on...
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • email
  • Google Buzz
  • LinkedIn
  • Meneame
  • PDF
  • RSS

Creative Commons License
The when geolocation becomes a problem by geometrus, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

This entry was posted in geo, php and tagged , , , . Bookmark the permalink.

3 Responses to when geolocation becomes a problem

  1. Per Christian says:

    Good article, I fully agree that geolocation is good for many things, but not language.

    I’m unable to verify that Google no longer uses geolocation, though. I work for a British company in Norway, and when I go to http://www.google.com, I’m redirected to http://www.google.co.uk, regardless of my language settings. (Thank god I’m not working for a Dutch company.)

  2. fulgen says:

    I agree, Christian – it has changed this behaviour. In Luxembourg, Google insists that I should use it either in German or in Dutch (!?!?), it depends on the day…

    Thank you for your comment!

  3. Pingback: Newsletter (August) – A geolocation special | Fublo Ltd blog

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>