如何在Django中的另一个模板标签内添加翻译模板标签? [英] How can I add a translation template-tag inside another template-tag in Django?

查看:55
本文介绍了如何在Django中的另一个模板标签内添加翻译模板标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的模板代码:

{{ can_edit|yesno:'Allow edit,View Only' }}

但是我想从我的翻译字符串中自动翻译它,所以我这样做了:

But I want to translate it automatically from my translation strings, so I did this:

{{ can_edit|yesno:'{% trans "option_allow_edit" %},{% trans "option_allow_edit" %}' }}

但是它不起作用,因为它转义了 {%trans%} 标签.

But it doesn't work, because it escapes the {% trans %} tags.

我该怎么办?

推荐答案

您应尝试使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆