It's a trap - Multilingual web applications

Posted: Saturday, 2009-11-21 10:26 | Tags: ItsATrap, Programming, Web

Say you're designing a multilingual web application. Where would you put the language information?

  • Carry it over with each request (generate hidden inputs)
  • Into the users session
  • Into the URL

The first approach is obviously quite tedious and more or less just included for completeness. No doubt you don't wanna do this except for a really small app or some rather unusual constraints (no cookies, framework that has hard constraints on URL scheme).

The second one looks like a really good idea:

  • You don't need to find out the users language with each request with url parsing or similar things,
  • You can freely choose your URLs after whatever scheme you like, language doesn't have to be a part of it.
  • You URLs can be exchanged between users of different languages, they will be displayed in each users favourite language to them.

So wheres the TRAP? Here a hint: Think of search engines.

Still don't see it?

Well took me some time, too. The problem is: If a search engine from some country indexes your page its bot will most probably not emulate/have cookie support. So all search engines in all countries will see and thus index the page in its default language (that one that appears when a user has no cookies enabled). This way the search engines won't find your site when the users enter keywords in their own language. What a crap.

So the answer is obvious: Put that information into your url. Or if you want detect it from the domain name (if you have one domain for each country/language <- distinguish carefully btw!)

Comment on twitter