buxeasywork / django-rosetta

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

UnicodeDecodeError at /rosetta/select/ru/0/ #102

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If Languages saves in DB (MySQL) there is exception during unicode
if language name not in English
FIX
replace line 308:
request.session['rosetta_i18n_lang_name'] = unicode([l[1] for l in 
settings.LANGUAGES if l[0] == langid][0])
to:
request.session['rosetta_i18n_lang_name'] = unicode([l[1] for l in 
settings.LANGUAGES if l[0] == langid][0], 'UTF-8')

What version of the product are you using?
Rosetta Version:        0.5.6
Django Version:     1.2.3
Python Version:     2.5.2

'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

Request Method:     GET
Django Version:     1.2.3
Exception Type:     UnicodeDecodeError
Exception Value:    

'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

Exception Location:     ./rosetta/views.py in lang_sel, line 308

Original issue reported on code.google.com by zhirafc...@gmail.com on 23 Feb 2011 at 10:19

GoogleCodeExporter commented 9 years ago
Hello, I'm having a hard time to reproduce this, I use e.g. this in my 
settings: 

LANGUAGES = (
    ('fr', _('Français')),
    ('ja', _('日本語')),
)

and this works fine in Rosetta. 

What encoding is your settings file in? 

Also, I'm not sure I understand what you mean by "If Languages saves in DB 
(MySQL)".

Thank you for your feedback.

Original comment by mbonetti on 7 Mar 2011 at 9:16

GoogleCodeExporter commented 9 years ago
that is mean that LANGUAGES looks like
settings.LANGUAGES = [
 ('en', 'English'),
 ('ru', '\xd0\xa0\xd1\x83\xd1\x81\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9'),
]
and this value was get by cursor.execute('SELECT * FROM 
mysupersettings_language')
problem was on converting this string 
'\xd0\xa0\xd1\x83\xd1\x81\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9' because
unicode('\xd0\xa0\xd1\x83\xd1\x81\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9')
---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)

/var/www/admitad/<ipython console> in <module>()

UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal 
not in range(128)

Original comment by rahalevi...@gmail.com on 9 Mar 2011 at 1:29