What is the best way to get an url parameter in a django translation? [duplicate]

So I have a site that sould support multiple languages, but when i have to translate a block with an url in it, i run into trouble. For example when I have something like:

{% blocktrans %}
This is an english sentence with a <a href="{% url 'app:link' %}">link <\a>.
{% endblocktrans %}

It raises an error as there can be no actions inside the blocktrans. So i tried to do it like:

{% with link='{% url "app:link" %}' %}
{% blocktrans %}
This is an english sentence with a <a href="{{ link }}">link <\a>.
{% endblocktrans %}
{% endwith %}

But sadly this also raises an error, saying: Could not parse the remainder: ''{%' from ''{%'

Does anyone know how to add an url to the translation without an ugly split? A split like:"

{% translate "this is an enlish sentence with a" %}<a href="{% url 'app:link' %}">{% translate "link" %}</a>.

As in different languages there might be different amounts of text before and after the 'split'. As in this case there should be space after the text link in other languages. Does anyone know how to put the url in the translation?

Back to Top