Reputation: 23
I'm using coffin to interface with Jinja2 for Django templating.
I've run into a situation where I need to translate this piece of text which looks like this:
<a href= "#"> This is a test <b> text </b>.</a> The quick brown <span class="red"> fox </span>
so, i'm currently doing something like this to translate it
< a href= "#">{% trans %}This is a test{% endtrans %} < b> {% trans %}text{% endtrans %} < /b>. < /a> {% trans %}The quick brown{% endtrans %} < span class="red"> {% trans %}fox{% endtrans %} < /span>
I can tell there must be an easier way to translate text which have html tags within them. What is the best way to proceed?
is this a valid way to do it?
{% trans %}<a href= "#">This is a test <b> text </b>. </a> The quick brown <span class="red"> fox </span>{% endtrans %}
Thanks!
Upvotes: 1
Views: 997
Reputation: 11
You can use HTML tags inside your .po file. This way, your translators will have the full context of your strings and they can adjust the tags to match the intended result.
Upvotes: 1
Reputation: 129784
While it is valid, it puts the burden of keeping valid HTML syntax on translators (not to mention being more volatile), so you should rather avoid doing this. AFAIR, you can do <a href="">{{ _('This is a test') }} <b>{{ _('text') }}</b> ...
in Jinja, if you want a syntax with less tag noise.
Upvotes: -1