Django i18n +模板包含标签

时间:2013-09-19 15:45:57

标签: django django-templates django-i18n

我需要呈现翻译的推荐书,并使用包含块作为推荐代码,如下所示:

{% include "includes/blog/testimonial.html" with text="This is the best product I've ever used!" name="Tim Z" description="Store Manager" %}

如何将blocktransinclude标记一起用于呈现已翻译的包含标记?

谢谢!

1 个答案:

答案 0 :(得分:7)

如果我理解正确,您希望将您提供的文字翻译成“包含”标签。如果这是正确的,只需事先将其翻译并将结果保存到变量:

{% 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 %}