views:

53

answers:

2

I'm implementing the routing and i18n part of my framework. I'm wondering if I should assume that

^[a-z]{2} 

Will be a locale, and if so use it. Or should I make the user populate a list with languages? Eg:

supported = [ 'en', 'es', 'it', 'ru', ]

So the developer has to manually define languages. And for the record, 90% of the sites here only use en only.

+3  A: 

Keep in mind that some languages need more than two characters to specify. Simplified Chinese is often "zh-CN" or "zh-HANS", and Traditional Chinese is "zh-TW" or "zh-HANT". Brazilian Portuguese is "pt-BR", and so on.

Ned Batchelder
+3  A: 

ISO 639 is the language code specs - but it defines more than one way

  • ISO 639-1: two-letter codes
  • ISO 639-2/T: three letter codes
  • ISO 639-2/B: three letter codes
  • ISO 639-3: three letter codes where dialects of a common root (Arabic Generic, Arabic Standard for example) are separate.

However is language actually a locale? EN for example most certainly isn't. Being British I want EN-UK content first, but I'm in the US. This means google redirects me to google.co.uk which is certainly not what I want.

blowdart