Hi list,

my django is completely utf8-configured. I'm using I18N and my msg-ids
(po-files) are utf8-encoded, too.

But now I've run into a strange problem: Translation of strings
containing non-ascii characters is working great in templates, but it
fails if I try to translate non-ascii strings in a view.

For example, this get's translated without problems:
{% trans "Lösung" %}

But this one fails:
from django.utils.translation import ugettext as _
def index(request):
    teststring = _("Lösung")
    [...]

This exception is raised when the view is called:
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.4/site-packages/django/core/handlers/
base.py" in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/django/myproject/../myproject/portal/views.py" in
index
  8. teststring = _("Lösung")
File "/usr/local/lib/python2.4/site-packages/django/utils/translation/
__init__.py" in ugettext
  61. return real_ugettext(message)
File "/usr/local/lib/python2.4/site-packages/django/utils/translation/
trans_real.py" in ugettext
  274. return do_translate(message, 'ugettext')
File "/usr/local/lib/python2.4/site-packages/django/utils/translation/
trans_real.py" in do_translate
  258. return getattr(t, translation_function)(message)

  UnicodeDecodeError at /
  'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in
range(128)
----------------------------------------------------------------------

Why does it work within templates but not within views?? What am I
doing wrong? Any hint?

(BTW, I'm using the current django trunk.)

TIA
-Stephan


--~--~---------~--~----~------------~-------~--~----~
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