imported tuples/variables don't get translated

49 views
Skip to first unread message

Ivo Brodien

unread,
Feb 8, 2011, 5:11:51 PM2/8/11
to Django users
If I import some tuple which is used for choices in a forms.RadioSelect widget, then the choices don’t get translated

models.py:

BOOL_CHOICES = ((True, _(u'Yes')), (False, _(u'No')))

forms.py:

from models import BOOL_CHOICES

1) does work an translates the choices
form.fields['accomdation'].widget = forms.RadioSelect(choices = ((True, _(u’Yes')), (False, _(u'No'))))

2) does not translate the choices
form.fields['accomdation'].widget = forms.RadioSelect(choices = BOOL_CHOICES)


something similar happens for a label

STATIC = _(u”mystring”)

...label = STATIC does not work
...label = _(STATIC) does work


Is this a bug or a desired behavior or am I missing something?

Marcos Moyano

unread,
Feb 8, 2011, 5:21:03 PM2/8/11
to django...@googlegroups.com
Are you doing: from django.utils.translation import ugettext_lazy as _ ?
or: from django.utils.translation import ugettext as _ ?

The first one shoud work.

Rgds,
Marcos


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




--
Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems.

Jamie Zawinski, in comp.emacs.xemacs

Ivo Brodien

unread,
Feb 8, 2011, 5:43:30 PM2/8/11
to django...@googlegroups.com
hey Marcos,

> Are you doing: from django.utils.translation import ugettext_lazy as _ ?
> or: from django.utils.translation import ugettext as _ ?
>
> The first one shoud work.

Indeed I used ugettext instead of ugettext_lazy

Thanks!

Reply all
Reply to author
Forward
0 new messages