如何使 Django blocktrans 中的空格和缩进无关紧要?

How to make spaces and indentation insignificant in Django blocktrans?

在某些 Django 模板中对以下 blocktrans 进行成像:

{% blocktrans %}
    Some Text
{% endblocktrans %}

对模板进行一些更改后,您可能希望缩进该块:

<div>
    {% blocktrans %}
        Some Text
    {% endblocktrans %}
</div>

这将更改翻译文件中的消息,并将其标记为模糊。从技术上讲,它是相同的消息(只是缩进不同)。

"unfuzzyfying"这些消息的整个过程是繁琐且容易出错的。

到目前为止我尝试了什么:

有没有办法让 blocktrans 中的缩进变得无关紧要?

根据文档here

Another feature {% blocktrans %} supports is the trimmed option. This option will remove newline characters from the beginning and the end of the content of the {% blocktrans %} tag, replace any whitespace at the beginning and end of a line and merge all lines into one using a space character to separate them. This is quite useful for indenting the content of a {% blocktrans %} tag without having the indentation characters end up in the corresponding entry in the PO file, which makes the translation process easier.

例如

<div>
    {% blocktrans trimmed %}
        Some Text
    {% endblocktrans %}
</div>

将在您的 PO 文件中生成条目 "Some Text"