为什么Django blocktrans工作在一个地方,而不是另一个? [英] Why is Django blocktrans working one place and not another?
问题描述
我有两个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屋!