【问题标题】:Django i18n + template include tagsDjango i18n + 模板包含标签
【发布时间】:2013-09-19 15:45:57
【问题描述】:

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

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

如何使用blocktransinclude 标签来呈现翻译后的包含标签?

谢谢!!

【问题讨论】:

    标签: django django-templates django-i18n


    【解决方案1】:

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

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

    【讨论】:

    • 完美,我现在就试试这个,然后告诉你。
    • 顺便说一句,包含的模板可以访问主上下文,所以在这种情况下你可以写{% include "includes/blog/testimonial.html" with name="Tim Z" %},但我想说明一个更大的点。
    猜你喜欢
    • 1970-01-01
    • 2016-08-12
    • 2018-02-22
    • 2013-02-13
    • 2017-01-05
    • 2011-08-10
    • 2014-05-03
    • 2013-06-14
    • 2021-05-24
    相关资源
    最近更新 更多