Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: Passing the result of {% trans %} via a filter

I have a string that I want passed via the "linebreaks" filter.

{% trans "my string"|linebreaks %}

Doesn't work.

Is there another way ?

like image 277
Boris Avatar asked Apr 18 '10 08:04

Boris


2 Answers

See filter.

{% filter force_escape|lower %}
    {% blocktrans %}This text will be translated, HTML-escaped, and will appear in all lowercase.{% endblocktrans %}
{% endfilter %}
like image 124
Ignacio Vazquez-Abrams Avatar answered Sep 28 '22 08:09

Ignacio Vazquez-Abrams


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

{% blocktrans with value|filter as myvar %}
This will have {{ myvar }} inside.
{% endblocktrans %}
like image 27
Dmitry Shevchenko Avatar answered Sep 28 '22 08:09

Dmitry Shevchenko