Bugs item #1080864, was opened at 2004-12-07 21:23 Message generated for change (Comment added) made by childsplay You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1080864&group_id=5470
Category: Python Library Group: Python 2.3 Status: Open Resolution: None Priority: 5 Submitted By: stas Z (childsplay) Assigned to: Nobody/Anonymous (nobody) Summary: locale.py doesn't recognize valid locale setting Initial Comment: [EMAIL PROTECTED]:~$ locale LANG=nb_NO [...] [EMAIL PROTECTED]:~$ python Python 2.3.4 (#2, Sep 24 2004, 08:39:09) [GCC 3.3.4 (Debian 1:3.3.4-12)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import locale >>> locale.getdefaultlocale() Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.3/locale.py", line 346, in getdefaultlocale return _parse_localename(localename) File "/usr/lib/python2.3/locale.py", line 280, in _parse_localename raise ValueError, 'unknown locale: %s' % localename ValueError: unknown locale: nb_NO >>> ---------------------------------------------------------------------- >Comment By: stas Z (childsplay) Date: 2004-12-08 16:09 Message: Logged In: YES user_id=638376 This is what I've put into /python2.3/locale.py: locale_alias = {.... ....... 'bokmål': 'nb_NO.ISO8859-1', 'nb': 'nb_NO.ISO8859-1', 'nb_no': 'nb_NO.ISO8859-1', 'nynorsk': 'nn_NO.ISO8859-1', 'nn': 'nn_NO.ISO8859-1', 'nn_no': 'nn_NO.ISO8859-1', .... .... } I have tested it on a number of apps and it fixes the problem. ---------------------------------------------------------------------- Comment By: M.-A. Lemburg (lemburg) Date: 2004-12-08 14:06 Message: Logged In: YES user_id=38388 Please provide some authorative source which describes the locale your are using (nb_NO) and the commonly used encoding for that locale (see the existing dictionary in locale.py). ---------------------------------------------------------------------- Comment By: stas Z (childsplay) Date: 2004-12-08 13:29 Message: Logged In: YES user_id=638376 The reason I use getdefaultlocale(), is to get a platform independant way of getting the systems locale setting. The biggest advantage is that on Windows a "Linux like" locale is returnt so that I can use the same language support stuff on all platforms. (Win,Linux,OSX). Besides, what's the problem of adding the missing locale? ---------------------------------------------------------------------- Comment By: M.-A. Lemburg (lemburg) Date: 2004-12-08 10:05 Message: Logged In: YES user_id=38388 The LANG (and other similar OS environment variables) define what the user wishes to see being used as locale in the applications that are started in that environment. See the setlocale man page for details. On some OSes such as Windows these settings are stored differently, which is why the locale module has provisions for finding these settings (thanks to Fredrik). ---------------------------------------------------------------------- Comment By: Martin v. Löwis (loewis) Date: 2004-12-08 08:04 Message: Logged In: YES user_id=21627 There is no "default locale setting" in most operating systems. In what sense is the value of the LANG environment variable a "default"? ---------------------------------------------------------------------- Comment By: M.-A. Lemburg (lemburg) Date: 2004-12-08 00:08 Message: Logged In: YES user_id=38388 Of course, I don't agree with you, Martin :-) locale.getdefaultlocale() does server a purpose, namely that of getting the default locale setting. The encoding information is an often used extension when setting the locale in the OS environment. If not set, the module provides common defaults. The locale "nb_NO" is not known to the module alias table. Which locale, language and encoding would that be ? ---------------------------------------------------------------------- Comment By: Martin v. Löwis (loewis) Date: 2004-12-07 23:13 Message: Logged In: YES user_id=21627 To get the default encoding for the current locale, you should use locale.getpreferredencoding(). You should not use getdefaultlocale becaus it is (IMO) inherently broken, and should not have been part of the standard library in the first place. ---------------------------------------------------------------------- Comment By: Jarek Zgoda (zgoda) Date: 2004-12-07 22:39 Message: Logged In: YES user_id=92222 getdefaultlocale() is often used to get default encoding for current system locale. And, if function is provided in standard library, why shouldn't one use it? ---------------------------------------------------------------------- Comment By: Martin v. Löwis (loewis) Date: 2004-12-07 21:25 Message: Logged In: YES user_id=21627 Why do you want to use getdefaultlocale()? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1080864&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com