I am just getting started with Django internationalization and trying to understand the best practices for using {% blocktrans %}
. Is it preferable to use one {% blocktrans %}
for each paragraph, or should I have one big {% blocktrans %}
that contains many paragraphs?
Having one big {% blocktrans %}
is faster and makes my template look cleaner, but my concern is that:
- it causes HTML tags (like
<p>...</p>
) to become part of the translation string - If I change one thing in one part of my huge block, the
msgid
would change, which seems like it could affect the other paragraphs. If I have smaller blocks, the changes would be more isolated (I suppose). - If I make a formatting change like adding/removing a newline in between paragraphs, that would change the
msgid
.
I am also wondering about formatting. Are there any complications to having line breaks inside a {% blocktrans %}
? Or having leading spaces? e.g.:
{% blocktrans %}
You have {{ num_messages }} messages.
Another sentence.
{% blocktrans %}
Any recommendations are welcome.