I would like to assign the output of a blocktrans block to a template variable.
You can do that using the trans tag like so:
{% trans "Some text to translate" as foo %}
However you can't do the same with a blocktrans tag. I don't see it in the documentation that you can do this.
Django 1.9 added an asvar
component to blocktrans
. An example from the docs:
{% blocktrans asvar the_title %}The title is {{ title }}.{% endblocktrans %}
<title>{{ the_title }}</title>
<meta name="description" content="{{ the_title }}">
Unfortunately, it seems that before that was added you needed some other way of doing it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With