#27730: i18n: trans tag with "as" does not work across blocks
------------------------------------------------+------------------------
Reporter: Peter Bittner | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Internationalization | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
The `trans ... as` tag as documented in
[https://docs.djangoproject.com/en/1.10/topics/i18n/translation/#trans-
template-tag topics / i18n / translation] only works in an isolated
fashion outside blocks or inside of blocks. In other words, it does not
work across blocks when defined outside of them, i.e. "globally" in a
template.
The following example doesn't work: -- the value of `{{ title }}` will be
empty.
{{{
{% extends 'base.html' %}{% load i18n %}
{% trans "My Projects" as title %}
{% block head_title %}{{ title }}{% endblock %}
{% block content %}
<h2>{{ title }}</h2>
{% endblock %}
}}}
This behavior is not documented, and neither is this behavior intuitive.
The same behavior and/or lack of documentation is true for `blocktrans
asvar ...`.
== Enhancement or Documentation Fix?
This issue should be clarified and either fixed in the documentation (if
the observations are confirmed), or alternatively changed in the template
tag's behavior (if feasible and sensible).
Which route should be taken? Please clarify.
== See Also
-
[https://github.com/django/django/commit/839edcebb39f55acf163266f1ce1f0dc537de95b#commitcomment-20449057
GitHub commit 839edce] (comment) -- ''additional information''
- [http://stackoverflow.com/questions/14798078/trans-string-as-my-
translated-string-is-not-rendering-content-in-templat Related
StackOverflow question] -- ''{% trans “string” as my_translated_string %}
is not rendering content in template''
--
Ticket URL: <https://code.djangoproject.com/ticket/27730>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.240ee48d9e8f55d62dd35de04eda82c9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.