[web-devel] [yesod] Messages / i18n question: how to handle "xx-xx" languages

Michael Snoyman michael at snoyman.com
Fri Jul 8 06:22:53 CEST 2011

On Thu, Jul 7, 2011 at 1:29 AM, Markus Barenhoff <mb at niulabs.com> wrote:
> On 6 July 2011 22:08, Michael Snoyman <michael at snoyman.com> wrote:
>> I *don't* have a hard and fast answer here, these are my thoughts. I'd
>> like to hear what people think about this.
>> My advice is to use one or the other: either "en" for all English
>> versions, or "en-us" and "en-uk". I think all browsers will send both
>> versions in the request headers.
>> If you want to have a system where you can choose American or British
>> English, and default to American, why not provide "en-uk" and "en"?
> I think it would be nice if the "most specific" version availible is choosen.
> something like:
> 1.) for every preferred language of the client check in order of preference:
> 2.) if language has form xx-yy check if xx-yy.msg is availible. if not
> check if xx.msg is availible.
> 3.) if both in 2.) are not availible, check for next prefferred
> language. if no more langs are availible use the default language.

It's tempting, but here's the problem. Let's say someone has a
language list like "en-us, en-gb, en". In this case, the user
preference is for American, then British, and finally generic English.
If our application provides both British and generic English,
following your scheme would result in usage of generic English, even
though the user would prefer British English.

How about a slight modification: first go through the user's list
precisely as specified. If there are no matches, then test the
non-localized version of languages. If there are still no matches,
then use the default language.


More information about the web-devel mailing list