carlxaeron / django-rosetta

Automatically exported from code.google.com/p/django-rosetta
MIT License
0 stars 0 forks source link

trying to use an unicode non-ASCII name of a language leads to UnicodeDecodeError #30

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
For example I have:

LANGUAGES = (
  ('en', 'English'),
  ('fr', 'Francais'),
  ('de', 'Deutsch'),
  ('pt', 'Portugues'),
  ('es', 'Espanol'),
  ('pl', 'Polski'),
  ('it', 'Italiano'),
  ('sq', 'Shqip'),
  ('bs', 'bosanski'),
  ('sr', 'српски'),
  ('hr', 'Hrvatski'),
  ('nl', 'Nederlands'),
)

Then when trying to select locale/sr/LC_MESSAGES/django.po
I get this:

Environment:

Request Method: GET
Request URL: http://stopsoftwarepatents.eu/rosetta/select/sr/0/
Django Version: 1.0-final-SVN-unknown
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.comments',
 'petition.app02',
 'petition.rosetta',
 'petition.registration']
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')

Traceback:
File "/var/lib/python-support/python2.5/django/core/handlers/base.py" in
get_response
  86.                 response = callback(request, *callback_args,
**callback_kwargs)
File "/var/lib/python-support/python2.5/django/views/decorators/cache.py"
in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/home/pet/petition/rosetta/views.py" in lang_sel
  226.         request.session['rosetta_i18n_lang_name'] = unicode([l[1]
for l in settings.LANGUAGES if l[0] == langid][0])

Exception Type: UnicodeDecodeError at /rosetta/select/sr/0/
Exception Value: 'ascii' codec can't decode byte 0xd1 in position 0:
ordinal not in range(128)

Also the name of the language српски is not shown on the blue stripe on
rosetta/pick/

Original issue reported on code.google.com by goo...@miernik.name on 27 Sep 2008 at 3:55

GoogleCodeExporter commented 8 years ago
Oh, sorry, I need to use:

LANGUAGES = (
  ('en', u'English'),
  ('fr', u'Francais'),
  ('de', u'Deutsch'),
  ('pt', u'Portugues'),
  ('es', u'Espanol'),
  ('pl', u'Polski'),
  ('it', u'Italiano'),
  ('sq', u'Shqip'),
  ('bs', u'bosanski'),
  ('sr', u'српски'),
  ('hr', u'Hrvatski'),
  ('nl', u'Nederlands'),
)

Now all OK, please close.

Original comment by goo...@miernik.name on 27 Sep 2008 at 4:10

Attachments:

GoogleCodeExporter commented 8 years ago
Yup: language names in your settings should be Unicode. Closing as per 
reporter's request.

Original comment by mbonetti on 27 Sep 2008 at 7:46