Skip to content

Commit 58a0a45

Browse files
committed
[book][translation] Modifying the translation filter escape description
1 parent b02ba49 commit 58a0a45

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

book/translation.rst

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff 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
722722
texts* 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
~~~~~~~~~~~~~

0 commit comments

Comments
 (0)