← Back to team overview

ubuntu-accomplishments-contributors team mailing list archive

Re: Internationalization and localization of the web editor

 

On 03/04/12 06:53, Janos Gyerik wrote:
>>  * Is there a way in Python in which we can detect which ISO code is
>> the default language for the user's machine?
> Maybe the LANG env variable? For the web editor, browsers have
> preferred language setting and accepted languages setting, don't
> remember the names but I'm sure we can easily find it when we get
> there.

locale.getdefaultlocale()
http://docs.python.org/library/locale.html

>
>>  * We will be storing the different translations as a sub-folder in
>> the accomplishments set (e.g. ~/accomplishments/ubuntu-community/fr/
>> and ~/accomplishments/ubuntu-community/de/) - is there a master list
>> of country codes we can use to know how to name these sub-folders?
> Yeah somebody please answer that...
>
> So the 2-letter won't cut it, because as Bruno pointed out Asturian
> doesn't have one, and we also need country variants like en_gb. So
> maybe 3-letter code + country variant, like:
> eng_gb
> eng_us
> hun_hu
> ast_es
> ?

Well, the problem is that the system locale will use the 2 letter code
if it can and mapping from 2 letter to 3 letter code is not always
straightforward. So the simplest way to deal with it would probably be
to use the first item of the tuple returned by locale.getdefaultlocale.
It doesn't matter if some codes are 2 letters and others are 3 letters.

Another thing we should probably support is the concept of fallback,
i.e. to be able to fallback to the base language locale if the variant
is not found. So, for example, if the locale is en_au, check for en_au
first and if not found check for en. Otherwise, you will have to work
out all the country variants every time you add a new language, which
can be rather messy (think Spanish or English!)

Applying those two principles, you could have something like this:

en
en_gb
es
es_mx
ast

This makes the code a wee bit more complicated but it saves a massive
amount of maintenance in the long term! And it would make the web editor
and python code consistent.

>
> I wonder how Ubuntu sets the locale variables when using Asturian...

I suppose we could ask an Asturian user :-)

Bruno



Follow ups

References