[Django]-Django – putting HTML tags inside blocks of text subject to translation

0👍

Does Django provide a way to include HTML tags in translation phrases? And if not, what is the cleanest work-around ?

The way to do it is exactly as you did it. It’s totally fine to occasionally have some markup inside your blocktrans blocks.

I don’t know why it doesn’t work with your <strong> tag.I tested this on my django playground and it perfectly worked even with the markup included. The issue must be something else.

That’s what the gettext documentation says about this:

HTML markup, however, is common enough that it’s probably ok to use in
translatable strings. But please bear in mind that the GNU gettext
tools don’t verify that the translations are well-formed HTML.

👤trixn

Leave a comment