locale support and 4.10

Hye-Shik Chang hyeshik at gmail.com
Mon Mar 7 00:30:24 EST 2005


On Sat, 05 Mar 2005 15:42:23 +1000, Timothy Smith
<timothy at open-networks.net> wrote:
> i'm trying to setlocale() on 4.10, and it appears the python package
> doesn't support this under 4.10.
> 
> Python 2.3.3 (#2, Apr 28 2004, 22:48:37)
> [GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import locale
>  >>> locale.setlocale(locale.LC_NUMERIC, 'us')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/local/lib/python2.3/locale.py", line 381, in setlocale
>     return _setlocale(category, locale)
> locale.Error: unsupported locale setting
>  >>>
> 
> the exact same thing works under windows xp.
> 
> do i have to compile it with locale support?
> 

>>> import locale
>>> locale.setlocale(locale.LC_NUMERIC, 'us')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.2/locale.py", line 372, in setlocale
    return _setlocale(category, locale)
locale.Error: locale setting not supported
>>> locale.setlocale(locale.LC_NUMERIC, 'en_US.ISO8859-1')
'en_US.ISO8859-1'
>>> locale.format('%g', 12.34)
'12.34'
>>> locale.setlocale(locale.LC_NUMERIC, 'fr_FR.ISO8859-1')
'fr_FR.ISO8859-1'
>>> locale.format('%g', 12.34)
'12,34'


You must specify exact locale name in FreeBSD.
eg) en_US.ISO8859-1 en_US.ISO8859-15 or etc.

Hye-Shik



More information about the Python-list mailing list