bug #25744 [TwigBridge] Allow label translation to be safe (MatTheCat)
This PR was merged into the 2.7 branch.
Discussion
----------
[TwigBridge] Allow label translation to be safe
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | ~
| Fixed tickets | ~
| License | MIT
| Doc PR | ~
After overriding `TranslationExtension`'s `trans` filter to make it safe I noticed form labels were still escaped because of `label` in
```twig
{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}
```
Replacing this ternary with `if`/`else` allows `trans` return to be safe.
WDYT?
Commits
-------
041c42db6a
Allow trans filter to be safe
This commit is contained in:
commit
c6453353d4
@ -219,7 +219,13 @@
|
|||||||
{% set label = name|humanize %}
|
{% set label = name|humanize %}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}</label>
|
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
|
||||||
|
{%- if translation_domain is same as(false) -%}
|
||||||
|
{{- label -}}
|
||||||
|
{%- else -%}
|
||||||
|
{{- label|trans({}, translation_domain) -}}
|
||||||
|
{%- endif -%}
|
||||||
|
</label>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endblock form_label -%}
|
{%- endblock form_label -%}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user