我需要呈现一个翻译后的推荐,我使用一个包含 block 作为推荐代码,如下所示:
{% include "includes/blog/testimonial.html" with text="This is the best product I've ever used!" name="Tim Z" description="Store Manager" %}
如何使用 blocktrans
和 include
标签来呈现翻译后的包含标签?
谢谢!!
最佳答案
如果我理解正确,您想将您提供的文本翻译成“包含”标签。如果这是正确的,只需预先翻译并将结果保存到变量中:
{% trans "This is the best product I've ever used!" as text %}
{% trans "Store Manager" as description %}
{% include "includes/blog/testimonial.html" with text=text name="Tim Z" description=description %}
关于Django i18n + 模板包含标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18899295/