Django: passing result {% trans%} through a filter

I have a string that I want to pass through the "linebreaks" filter.

{% trans "my string"|linebreaks %}

Does not work.

Is there another way?

+5
source share
2 answers

See filter.

{% filter force_escape|lower %}
    {% blocktrans %}This text will be translated, HTML-escaped, and will appear in all lowercase.{% endblocktrans %}
{% endfilter %}
+10
source

If you need to filter before translating, you can also use:

{% blocktrans with value|filter as myvar %}
This will have {{ myvar }} inside.
{% endblocktrans %}
+3
source

All Articles