Localized month names?

Peter Otten __peter__ at web.de
Tue Mar 14 06:44:26 EST 2006


Sibylle Koczian wrote:

> Benji York schrieb:
>> Jarek Zgoda wrote:
>> 
>>> How do I get a list of localized month names for current locale? The
>>> first thing that came to my mind was an ugly hack:
>> 
>> 
>>>>> import locale
>>>>> locale.nl_langinfo(locale.MON_1)
>> 'January'
>> 
> 
> What did you leave out? 

Nothing, most likely.

> I get 
> 
> Traceback (most recent call last):
>   File "<pyshell#3>", line 1, in -toplevel-
>     locale.nl_langinfo(locale.MON_1)
> AttributeError: 'module' object has no attribute 'nl_langinfo'
> 
> (Python 2.4, german Windows XP Pro)
> 
> Moreover, 'January' is probably not localized.

Python 2.4.2 (#4, Nov 19 2005, 13:25:59)
[GCC 3.3.3 (SuSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.nl_langinfo(locale.MON_1)
'January'
>>> locale.setlocale(locale.LC_ALL, "")
'de_DE.UTF-8'
>>> locale.nl_langinfo(locale.MON_1)
'Januar'


Peter



More information about the Python-list mailing list