Django gettext <br> tag

Thank you for checking my question.

I try to use gettext and serve my django website in another languages.

  • I want to add a class to the br tag. As shown in ↓, an error does not occur if there is only a br tag, {% trans "I am a student. <br> I am a man."%} But as shown below, if you add a class, an error will occur. {% trans "I am a student. <br class="aaaa"> I am a man."%}

Could you teach me is there any good solution?

You have many possibilities:

Use class in wrapped HTML tag, for example div:

<-- in html -->
<div class="aaaa"> {% trans "I am a student. <br> I am a man."%}</ div>

don't forget about css:

.aaaa br {

you can use blocktranslate template tag:

more here:

of course, you can use two template tags:

<div class="aaaa"> 
{% trans "I am a student."%}
</ div> 
<div class="bbb"> 
{% trans "I am a man."%}
</ div>

i don't like the last solution: if first trans bounded with second trans and they should be translated together.

Back to Top