Friday, October 29, 2010

to_locale case formatting

Hi, everyone.

When I call to_locale on a language code, it acts as I expected. But,
when I call it on an already formated locale, it will lowercase the
region code.

>>> from django.utils.translation import to_locale
>>> to_locale('en-us')
'en_US'
>>> to_locale('en_US')
'en_us'
>>> to_locale('en_us')
'en_us'

Wasn't it supposed to always return a locale in the same format? In
theory, shouldn't the following statement be True?

to_locale('en-us') == to_locale('en_US') == to_locale('en_us') ==
to_locale(to_locale('en-us'))


django.utils.translation.trans_real.to_locale allows me to specify if
I'd like to always get a lowercase locale using the to_lower
parameter. But this parameter is NOT available in
django.utils.translation.to_locale neither in
django.utils.translation.trans_null.to_locale.

Am I missing something here? (I'm new to i18n and l10n.) I don't think
it's a big deal (since all locale codes I'm using follow the same
format), but I've just spent some time trying to understand why it
acts this way and couldn't figure it out.

Thank you.
Mathias Kretschek

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment