Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#15157 closed (fixed)

Literals marked up with _() in templates are translated at compilation time, don't change when locale is switched

Reported by: Ramiro Morales Owned by: nobody
Component: Internationalization Version: dev
Severity: Keywords: activate deactivate template
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This issue had been reported in the -dev mailing list a while back: https://groups.google.com/d/topic/django-developers/rxjxtwEMAEY/discussion

>>> from django.utils.translation import activate, deactivate
>>> from django.template import Template, Context
>>>
>>> activate('de')
>>> t = Template("{{ _('No') }}")
>>> activate('nl')
>>> t.render(Context({}))
>>> 'Nein' # Should be 'Nee'

Proposed fix changes a call from ugettext() to ugettext_lazy() in handling of the '_(', ')' literals during template variables resolution. Tests included also verify trans and blocktrans tags work, just in case.

Attachments (1)

15157.diff (6.1 KB ) - added by Ramiro Morales 14 years ago.
Proposed fix, includes tests

Download all attachments as: .zip

Change History (6)

by Ramiro Morales, 14 years ago

Attachment: 15157.diff added

Proposed fix, includes tests

comment:1 by Ramiro Morales, 14 years ago

Summary: Literals marked up with _() intemplates are translated at template compilation time, don't change when locale is switchedLiterals marked up with _() in templates are translated at compilation time, don't change when locale is switched

comment:2 by Jannis Leidel, 14 years ago

milestone: 1.3
Triage Stage: UnreviewedReady for checkin

comment:3 by Ramiro Morales, 14 years ago

Resolution: fixed
Status: newclosed

(In [15327]) Fixed #15157 -- Modified evaluation of literals surrounded by _(' and ')' in templates to be evaluated at render time instead of at compile time by using ugettext_lazy. Thanks Jonathan S for the report.

comment:4 by Ramiro Morales, 14 years ago

(In [15328]) [1.2.X] Fixed #15157 -- Modified evaluation of literals surrounded by '_(' and ')' in templates to be done at render time instead of at compile time by using ugettext_lazy. Thanks Jonathan S for the report.

Backport of [15327] from trunk

comment:5 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top