On Wednesday 22 January 2014 15:59:23 Henrique Romano wrote:
> On Wed, Jan 22, 2014 at 11:38 AM, gilberto dos santos alves <
> 
> [email protected]> wrote:
> > please look details about on [1]. if you put
> > 
> > # -*- coding: utf-8 -*-  on sources and config files for django your
> > string "português" will be automatically handled.
> 
> Can you just try what I reported?  For example:
> 
> $ cat ~/foofoo.py
> # -*- coding: utf-8 -*-
> from django.utils.translation import ugettext
> 
> print ugettext("Português")
> $ python ~/foofoo.py
> Traceback (most recent call last):
> ...
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 7:
> ordinal not in range(128)
> 
> So, I'm not sure what you are talking about.

This has nothing to do with the LANGUAGES setting, or the string being a 
language name. it just so happens that ugettext tries to return unicode, and 
so for an untranslated string s it returns unicode(s). You can get the same 
error by writing

        unicode("Português")

You should make sure that every string you pass to unicode(), directly or 
indirectly, is either a unicode object or an ASCII-only string (except in 
cases where you also pass the encoding); but that is general Python, not 
Django-specific.

As far as file headers are concerned, you may want to use

        from __future__ import unicode_literals

which really does make all your strings unicode.

Please take further discussion of this to django-users or other forums.

HTH,
        Shai.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/201401221639.43305.shai%40platonix.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to