Literals marked up with _() in templates are translated at compilation time, don't change when locale is switched
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.
Change History
(6)
Summary: |
Literals marked up with _() intemplates are translated at template compilation time, don't change when locale is switched → Literals marked up with _() in templates are translated at compilation time, don't change when locale is switched
|
milestone: |
→ 1.3
|
Triage Stage: |
Unreviewed → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
Proposed fix, includes tests