On Wed, Jan 22, 2014 at 12:43 PM, Ramiro Morales <[email protected]> wrote:
> 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?
>
I'm using django-cms, I want to support only two languages in my system:
English and Portuguese.
- Why are you using gettext() at the module level? You should use
> ugettext_lazy() or ugettex_noop()
>
That was just an example, ugettext_* returns a functional.proxy, which
doesn't try to render the string when you print it on the screen, but if
you try to do it you will see the same result.
- 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?
>
I didn't care about the correct encoding, I used the interactive session
just to show that a _unicode_ string is necessary for ugettext.
> - 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?
>
> Yes.
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.
>
As I wrote above, it "works" because it is returning a functional.proxy
object, if you try to print this object as string, you will see the same
error.
--
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/CA%2BEHud%2BDqchJmji7rzNeD3nebLeavArnWDhXNtXNA1KfYNkJBA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.