Django Templates - should I place HTML tags inside blocks of text subject to translation? [duplicate]

Is there any way to simplify the translation process when I have phrases with links and other HTML elements in them ?

Currently I am breaking long phrases into multiple translate tags which don't translate properly the meaning of the whole phrase:

           <span class="text-sm">
                {% translate "Please" %}
                <a class="inline font-semibold cursor-pointer text-blue-600 border-b-2 border-transparent hover:border-b-2 hover:border-blue-600"
                   href="{% url "shop:login" %}">
                  {% translate "login" %}
                </a>
                {% translate "to place your order. If you don’t have an account yet, you can" %}
                <a class="inline font-semibold cursor-pointer text-blue-600 border-b-2 border-transparent hover:border-b-2 hover:border-blue-600"
                   href="{% url "shop:register" %}">
                  {% translate "register" %}
                </a>
                {% translate "here." %}
              </span>

I have thought about using blocktrans, but this will carry the html tags into the .po file and maybe even translate the applied Tailwind CSS classes:

<span class="text-sm">
  {% blocktrans %}
    Please
    <a class="inline font-semibold cursor-pointer text-blue-600 border-b-2 border-transparent hover:border-b-2 hover:border-blue-600" href="{% url "shop:login" %}">
      login
    </a>
    to place your order. If you don’t have an account yet, you can
    <a class="inline font-semibold cursor-pointer text-blue-600 border-b-2 border-transparent hover:border-b-2 hover:border-blue-600" href="{% url "shop:register" %}">
      register
    </a>
    here.
  {% endblocktrans %}
</span>

Is there a way of doing this properly so that we can translate the whole phrase and keep the whole meaning, not just bits of it ?

Back to Top