views:

199

answers:

1

I have a site that has all its content translated to multiple languages and has no accounts (to set prefered language there). I can detect preferred language using Accept-Language, ip or anything else. I have 3 ways to store user language selection:

  1. Detect language and store it in cookie/session and allow switching language (and also store it in cookie/session)
  2. Use detected language if there is no language specified in url, and show links to url with different language
  3. Use default site language and show links to other languages

Storing langage in url can be of any type: different domain, subdomain, or somewhere in url

I think about first case as it allows me to send one url to anyone and it will be presented to them in their preferred language. But another opinion is that different language means different data, so it must have different link.

+7  A: 

Store it in the URL as part of pathinfo, preferably as close as possible to the domain name. E.g. http://example.com/en/page or http://en.example.com/page. It's not only SEO friendlier, but it is also guaranteed to work with cookie/session-less clients.

You can also choose for a combination. If the client supports cookies, you could make use of it to store the "preferred" language. If this information is absent in the session, then redirect to an URL which displays the language which matches the Accept-Language header the most and store this language in the session (which is in most programming languages/frameworks by the way already backed by a cookie). If the user changes this information, then reflect the change in the session as well.

BalusC
Very comprehensive and reasonable answer.
Steven Sudit