On Wed, Apr 11, Sandro Dentella wrote:

> 
> Hi all,
> 
>   I'm having problems understanding an error that raises with gettext and an
>   accented letter. Italian translation of 'priority' is 'priorità', the text
>   to be translated is:
> 
>     subject = _("Priority changed in ticket #%(id)s %(title)s") % (
>                    {'id':instance.id, 'title':instance.title})
> 
>   that *works nicely* when run in this way:
> 
> 
>     # coding: latin-1
>     import os, sys
>     os.environ['DJANGO_SETTINGS_MODULE'] = 'jobs.settings'
>     from django.utils.translation import gettext as _
> 
>     subject = _("Priority changed in ticket #%(id)s %(title)s") % (
>       {'id': 11, 'title': 'abc'})
> 
>   but raises an error when run within a function in a callback connected
>   with a signal:
> 
> Traceback (most recent call last):
>  [...]
>   UnicodeDecodeError at /ticket/ticket/edit/21/
>   'ascii' codec can't decode byte 0xc3 in position 7: ordinal not in
>   range(128)
> 
> 
>    my understnding of the problem is clearly partial here. I don't
>    understand what changes when the function in run within django.
> 
>    Any hint?

is perhaps one of the format parameters (to the '%' operator) a unicode
string, such as 
   _("...") % {'id': 11, 'title': u'abc'}
                                 ^^^

In that case, python tries to convert the format string to unicode, but
it uses ASCII as default encoding ...

Michael

-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to