为什么Django blocktrans工作在一个地方,而不是另一个? [英] Why is Django blocktrans working one place and not another?

查看:311
本文介绍了为什么Django blocktrans工作在一个地方,而不是另一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个Django模板(Pinax 0.9.x项目),文本在 blocktrans 块中。一个正在工作,另一个是不工作。

I have two Django templates (in a Pinax 0.9.x project) with text in a blocktrans block. One is working and the other isn't.

正在工作的工作原理如下:

The one that's working looks like:

{% extends "site_base.html" %}

...

{% block body %}

    <h1>ABC</h1>

    <h2><em>DEF</em></h2>

    <p>
        {% blocktrans %}
        GHI
        ...

没有工作的是发生调试模式错误:

The one that's not working is getting a debug mode error of:

TemplateSyntaxError at /JKL/
Invalid block tag: 'blocktrans', expected 'endblock' or 'endblock body'

它遵循这些标题,源代码与 blocktrans 以红色突出显示:

It follows those headings by giving the following source code, with the blocktrans highlighted in red:

{% extends "site_base.html" %}
{% block head_title %}MNO{% endblock %}

{% block body %}
    <p>
        {% blocktrans %}
        PQR
        {% endblocktrans %}
    </p>

这两个代码块是否同构?如果不是,有什么区别?我应该做些什么来让他们的内容在 blocktrans 标签中工作的段落?

Are these two blocks of code isomorphic? If they aren't, what is the difference? What should I be doing to have paragraphs with their content working in blocktrans tags?

谢谢,

推荐答案

您必须加载 i18n 模板标签:

<!-- your_template.html -->
{% load i18n %}

这篇关于为什么Django blocktrans工作在一个地方,而不是另一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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