In Django templates, how would I translate a block that contains HTML? For example:
{% trans "Please" %}
<a href="{% url login %}?next={{ currentUrlPath }}">
{% trans "log in" %}
</a>
{% trans "in order to use MyApplicationName." %}
Splitting up translated strings allows me to change the HTML in the template at any time, but I guess it would make more sense to put it into a single translation string, like so:
{% url login as loginUrl %}
{% blocktrans %}
Please
<a href="{{ loginUrl }}?next={{ currentUrlPath }}">
log in
</a>
in order to use MyApplicationName.
{% endblocktrans %}
But then the HTML markup is in the translation string, i.e. if I wanted to change the HTML (e.g. CSS class for the anchor), I'd have to retranslate the string for each language.
Are there any better alternatives?