"Fulvio" wrote:

> > but it also looks as if the meaning of the word "localized" isn't clear to
> > you; if you changed the locale, those names will be translated
>
> Mine behave strangely. Linux localized for Italian, but Python (or its
> calander is in english)

Python defaults to the C locale, which is a minimal english locale.  To change 
this,
you have to tell the locale module

>>> import locale
>>> locale.setlocale(locale.LC_ALL)
'C'
>>> import calendar
>>> list(calendar.month_abbr)
['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 
'Nov', 'Dec']

>>> locale.setlocale(locale.LC_ALL, "") # get locale from environment
'sv_SE'
>>> list(calendar.month_abbr)
['', 'jan', 'feb', 'mar', 'apr', 'maj', 'jun', 'jul', 'aug', 'sep', 'okt', 
'nov', 'dec']

>>> locale.setlocale(locale.LC_ALL, "it_IT") # use explicit locale
'it_IT'
>>> list(calendar.month_abbr)
['', 'gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 
'nov', 'dic']

The point here is that this is a global setting; once you (or someone using 
your code)
change the locale, all locale dependent code changes behaviour.

>>> import locale, string
>>> print string.uppercase
ABCDEFGHIJKLMNOPQRSTUVWXYZ
>>> locale.setlocale(locale.LC_ALL, "it_IT")
'it_IT'
>>> print string.uppercase
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ

</F> 



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to