File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -718,7 +718,7 @@ You can also specify the message domain and pass some additional variables:
718718 {0} There is no apples|{1} There is one apple|]1,Inf] There are %count% apples
719719 {% endtranschoice %}
720720
721- The ``trans `` and ``transchoice` filters can be used to translate *variable
721+ The ``trans `` and ``transchoice `` filters can be used to translate *variable
722722texts * and complex expressions:
723723
724724.. code-block :: jinja
@@ -733,10 +733,21 @@ texts* and complex expressions:
733733
734734 .. tip ::
735735
736- As the translation tags are just wrappers around static block of texts,
737- which are never escaped by Twig, automatic output escaping is never
738- applied; but the automatic output escaping rules apply to the output of
739- filters.
736+ Using the translation tags or filters have the same effect, but with
737+ one subtle difference: automatic output escaping is only applied to the
738+ translated strings when using a filter. In other words, if you need to
739+ be sure that your translated string is *not * output escaped, you must
740+ apply the raw filter after the translation filter:
741+
742+ .. code-block :: jinja
743+
744+ {# no change is needed - the translated text is never escaped #}
745+ {% trans %}
746+ <h3>foo</h3>
747+ {% endtrans %}
748+
749+ {# With filters, you must unescape the translated text #}
750+ {{ '<h3>foo</h3>' | trans | raw }}
740751
741752 PHP Templates
742753~~~~~~~~~~~~~
You can’t perform that action at this time.
0 commit comments