#5846: locale.py fails if LANG is UTF-8
---------------------------------------------------------------+------------
          Reporter:  Patrick Lauber <[email protected]>  |         Owner: 
 nobody
            Status:  closed                                    |     Milestone: 
       
         Component:  Internationalization                      |       Version: 
 SVN   
        Resolution:  fixed                                     |      Keywords: 
       
             Stage:  Accepted                                  |     Has_patch: 
 0     
        Needs_docs:  0                                         |   Needs_tests: 
 0     
Needs_better_patch:  0                                         |  
---------------------------------------------------------------+------------
Comment (by [email protected]):

 I'm also Mac OS X Leopard user and I have same problem.

 {{{
 # locale
 LANG=
 LC_COLLATE="C"
 LC_CTYPE="UTF-8"
 LC_MESSAGES="C"
 LC_MONETARY="C"
 LC_NUMERIC="C"
 LC_TIME="C"
 LC_ALL=

 # python -c 'import locale; print(locale.getdefaultlocale());'
 Traceback (most recent call last):
   File "<string>", line 1, in <module>
   File
 
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py",
 line 441, in getdefaultlocale
     return _parse_localename(localename)
   File
 
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py",
 line 373, in _parse_localename
     raise ValueError, 'unknown locale: %s' % localename
 ValueError: unknown locale: UTF-8
 }}}

 When I simply exported variable LANG:
 {{{
 # export LANG=ru_RU.UTF
 # locale
 LANG="ru_RU.UTF-8"
 LC_COLLATE="ru_RU.UTF-8"
 LC_CTYPE="UTF-8"
 LC_MESSAGES="ru_RU.UTF-8"
 LC_MONETARY="ru_RU.UTF-8"
 LC_NUMERIC="ru_RU.UTF-8"
 LC_TIME="ru_RU.UTF-8"
 LC_ALL=
 }}}
 I had same error again.

 But when I did export for LC_CTYPE:
 {{{
 # export LC_CTYPE=ru_RU.UTF-8
 # locale
 LANG="ru_RU.UTF-8"
 LC_COLLATE="ru_RU.UTF-8"
 LC_CTYPE="ru_RU.UTF-8"
 LC_MESSAGES="ru_RU.UTF-8"
 LC_MONETARY="ru_RU.UTF-8"
 LC_NUMERIC="ru_RU.UTF-8"
 LC_TIME="ru_RU.UTF-8"
 LC_ALL=
 # python -c 'import locale; print(locale.getdefaultlocale());'
 ('ru_RU', 'UTF8')
 }}}

 It is because the sequence of environment variables check in python:
 LC_ALL, LC_CTYPE, LANG, LANGUAGE.

 Note for Mac users:

 {{{
 # export LC_CTYPE=ru_RU.UTF-8
 # locale
 LANG=
 LC_COLLATE="C"
 LC_CTYPE="ru_RU.UTF-8"
 LC_MESSAGES="C"
 LC_MONETARY="C"
 LC_NUMERIC="C"
 LC_TIME="C"
 LC_ALL=
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/5846#comment:8>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to