On Wed, Jan 5, 2011 at 12:21 PM, Jonathan S <[email protected]> wrote:
> I guess, we found a bug, not sure if it has been reported earlier and
> whether this is the right place to report.
>
> When a template contains translations in variables, like
> {{ _("text") }}, the text seems to be translated already during the
> creation of the Template object. Every following call of
> Template.render() will output the translation which was made earlier.
> (Possibly in the wrong language.)
>
> Templates are cached in 'django.template.loaders.cached.Loader', so
> this bug makes constructions like  {{ _("text")|upper }} impossible.

But you aren't using the i18n support correctly.

You aren't supposed to use _('Foo') as a standalone variable.
(see last paragraph here
http://docs.djangoproject.com/en/1.2/topics/i18n/internationalization/#other-tags)

Also,

* You need to load the i18n template tag library

* Use the trans tag.

Try using Template("{% load i18n %}{% trans 'Yes' %}").render(...)
to achieve what you want.

All this is covered in the docs:

http://docs.djangoproject.com/en/1.2/topics/i18n/internationalization/#specifying-translation-strings-in-template-code

-- 
Ramiro Morales

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

Reply via email to