On Wed, Jan 22, 2014 at 10:59 AM, Henrique Romano <chrom...@gmail.com>wrote:
> On Wed, Jan 22, 2014 at 11:38 AM, gilberto dos santos alves < > gsa...@gmail.com> 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. > You aren't telling us all the story. there are many missing parts in your description of the issue you are finding so far so I don't think it's right to jump straight to the "As per the documentation, it is not clear that you _must_ use a unicode string for the language name. ... What do you guys think about making it clear that the user should always use an unicode string for the LANGUAGES setting?" conclusion. Some questions: - What are you trying to do? Reducing the choics in the LANGUAGES setting? Do you intend to translate them from Portuguese to other laguages? - Why are you using gettext() at the module level? You should use ugettext_lazy() or ugettex_noop() - Why did you show us a python interactive session instead of a Python soruce code file? How do you thing the interpreter can deduce the encoding of a bare string in that case? - Why in both cases are you using Django without are for setting up the settings infrastructure first? - Is the foofoo.py file are you (or rather you text editor) actually using the utf-8 encoding? You link to the development documentation but the tests I performed below are against the latest 1.6.x stable branch code with Python 2.7.3 (another piece of information you don't give us): $ django-admin.py startproject lang_i18n $ cd lang_i18n/ $ cat foofoo.py # -*- coding: utf-8 -*- from django.utils.translation import ugettext, ugettext_lazy, ugettext_noop print(ugettext_lazy("Portugués")) $ file foofoo.py foofoo.py: Python script, UTF-8 Unicode text executable ramiro@mang:~/dtest/lang_i18n$ DJANGO_SETTINGS_MODULE=lang_i18n.settings python foofoo.py <django.utils.functional.__proxy__ object at 0x20bfcd0> So the (lazy) translation machinery is working. -- 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 django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. 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/CAO7PdF9NgfG35MvJ5X24M7cSb%3DuOmZLkgkR9250DuT7ESCZO%3Dw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.