Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在{%if….%}标记内添加{%trans";%%}标记_Python_Django_Internationalization - Fatal编程技术网

Python 在{%if….%}标记内添加{%trans";%%}标记

Python 在{%if….%}标记内添加{%trans";%%}标记,python,django,internationalization,Python,Django,Internationalization,我拥有的基本模板: {% load auth_extras %} {% if request.user|has_group:"Administrator" %} <li><a href="/admin/"> Admin Section &nbsp;</a></li> {% endif %} {% if request.user|has_group:"Moderator" %} <li><a href="/admin/"&g

我拥有的基本模板:

{% load auth_extras %}
{% if request.user|has_group:"Administrator" %}
<li><a href="/admin/"> Admin Section &nbsp;</a></li>
{% endif %}
{% if request.user|has_group:"Moderator" %}
<li><a href="/admin/">Admin Section </a></li>
{% endif %}
{%load auth_extras%}
{%if request.user |拥有_组:“管理员”%}
  • {%endif%} {%if request.user |拥有_组:“版主”%}
  • {%endif%}

    在这种情况下,如何将{%trans”“%}标记添加到“管理部分”???直接添加它是受限制的,因为我在标记中有标记,这是不允许的。或者最好问一下——在这种情况下该怎么办?

    你能用
    翻译吗。。。作为
    ?更多细节

    {%trans“Admin Section”作为adm_Section%}
    {%if request.user |拥有_组:“版主”%}
    
  • {%endif%}
    这完全可以执行
    {%if请求。用户|拥有_组:“版主”%}
  • {%endif%}
    。您的问题是什么?如果{%trans”“%}在if标记内,本地服务器将失败(很高兴为您提供帮助),或者您可以使用
    {%blocktrans%}
    ,(文档)[
    {% trans "Admin Section" as adm_section %}
    {% if request.user|has_group:"Moderator" %}
    <li><a href="/admin/"> {{ adm_section }}</a></li>
    {% endif %}