Reputation: 60799
Django's {% blocktrans %}
template tag doesn't support object attribute accesses, nor template filters. Is there any django library that will allow me to use object attributes and filters inside a blocktrans-type-tag?
Essentially I want to be able to write:
{% load ??? %}
{% blocktrans %}The price is €{{ object.price }}.{% endblocktrans %}
I know the standard Django advice is to use variables on the blocktrans
, but I want to avoid that. It results in a much larger template and involves much more typing and template rewriting in order to i18n-ify your django app.
Before I go and write this library myself, I want to see if anyone has done it yet.
Upvotes: 1
Views: 171
Reputation: 10256
You can try with {% with %}
:
{% with object.price as myprice %}
{% blocktrans %}The price is € {{ myprice }}.{% endblocktrans %}
Upvotes: 1