What to do with HTML in translations? I want to translate sentences with HTML in them. For example such a string ([login]
is a link):
Please [login] to view your profile.
I do not want to bother my translators with translating text with html intertwined. On the other hand, I do not want to bother with creating all the links in my views, like suggested in this question. So ideally I want a template-only solution to have the flexibility of crafting HTML, while allowing translators to only work with text strings.
For example, this pseudocode implements these requirements:
{% render as login_html %}
<a href="{{ url 'login' }}?next={{ request.path|urlencode }}">
{% trans "Login" %}
</a>
{% endrender %}
{% blocktrans with login=login_html %}
Please {{ login }} to view your profile.
{% endblocktrans %}
First, the login HTML is rendered and stored as login_url
. Then in my blocktrans, I can simply use {{ login }}
to give the rendered login HTML. Is there a (similar) solution to this problem, or would it require custom template tags?