Localization! If I tell you English then give me English


I know that the next logical step in web pages is to deliver more and more localized content. But i think that some companies and developers are taking to many shortcuts to achieve this! The most aggravating ones is defining the users preferred language based on his location! This I just wrong! And in this post I will explain you why I think that this is wrong and how to do it correctly!

Before we start a little word of explanation: I prefer my web sites in English (regardless of my mother tongue) but sadly my IP address belongs to an Austria ISP. So naturally all “geo-aware” websites know where my computer sits. OK, this is not bad but what drives me mad is what they do with that information.

Now that that is done lets start. So I fire up my browser and navigate to a geo-aware website, like IGN.com. so what do I see on my screen when the page has loaded? I see:

  • Local news…OK
  • Local release dates…OK
  • The adds are also local…OK
  • Everything on the freking page is in German…NOT OK

I am quite happy with the location related information but does my location really tell anything about my language preferences? The simple answer is NO IT DOES NOT! But how should the web page know your language preferences if it does not know you? Someone could ask at this time. The answer to this is so simple that 80% of web pages tend to ignore it:

The web page does not but my browser knows!

Each browser on the face of this earth send the desired language preferences to the server when making an request! Why this simple fact is ignored i do not understand! Here is the screen that proves it!

Language settings dialog in Firefox

Firefox language settings

So this “preference” gets send to the web server with every request I do! Take this and give me the page in the language I would like to see! I do not care about the adds and the offers but the actual page content could be displayed in the language I desire (If it exists). I do not expect this to be true for small local sites that are only published with one language. But for big multilingual sites that have all the content in English to show it in my location language just because my IP says so is just mocking the user!

If the content that I want is there then please give it to me!

Making it the right way is not that hard! I will take .NET with C# to make my point, but it is easily possible in all other languages.

If you are in a web application you can simply query the HttpContext for the data you need:

string[] languages = HttpContext.Current.Request.UserLanguages;

And that is it! Now you have the names of the users preferred cultures (this includes the language he wants). Just pick the first one and use that to resolve all your multi language resources.

Is that really that hard?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s