带占位符的模板中的翻译 [英] Translation in template with placeholders
问题描述
我的.po文件中有
msgid此字符串中将包含%s."
msgid "This string will have %s inside."
如何在模板中翻译?
我尝试过:
{%blocktrans%},此字符串的内部将包含{{value}}.{%endblocktrans%}
{% blocktrans %}This string will have {{ value }} inside.{% endblocktrans %}
和
{%blocktrans,其值为%%}.此字符串内部将包含{{value}}.{%endblocktrans%}
{% blocktrans with value as value%}This string will have {{ value }} inside.{% endblocktrans %}
都不适合我
推荐答案
As stated in the documentation, the strings should use Python's standard named-string interpolation syntax.
所以 {%blocktrans%},此字符串内部将有{{value}}.{%endblocktrans%}
将使用翻译字符串此字符串将具有%(value)s内部."
.
So {% blocktrans %}This string will have {{ value }} inside.{% endblocktrans %}
will use the translation string "This string will have %(value)s inside."
.
这篇关于带占位符的模板中的翻译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!