← Back to team overview

ubuntu-accomplishments-contributors team mailing list archive

Re: Internationalization and localization of the web editor

 

On 3 April 2012 14:41, Bruno Girin <brunogirin@xxxxxxxxx> wrote:
> 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

Perfect, thanks!

>> 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.

Agreed. So I am thinking in the accomplishment set it I will create an
'en' sub-folder and this can be the default sub-folder. As an example,
if I have en_US installed but there is no en_US sub-folder, it will
then load 'en' instead. We could do this by checking if in en_US if
there is a _US and if not we just default to the 'en' sub-folder.

I can even do this at an accomplishment level. As an example if en_US
has all the accomplishments other than first-bug.accomplishment, we
can load first-bug.accomplishment from the fall-back of 'en'.

   Jono

-- 
Jono Bacon
Ubuntu Community Manager
www.ubuntu.com / www.jonobacon.org
www.identi.ca/jonobacon www.twitter.com/jonobacon


Follow ups

References