【发布时间】:2015-03-27 09:06:08
【问题描述】:
我希望我的 django 模板变量可以翻译。我为此使用了 {% blocktrans %}。
这段代码是否正确并且可以优化。我的意思是写得更好?循环或类似的东西。
{% for obj in objects %}
{% blocktrans with obj.user as user and obj.country as country and obj.b_day as b_day %}
<tr>
<td>{{ user }}</td>
<td>{{ country }}</td>
<td>{{ b_day }}</td>
</tr>
{% endblocktrans %}
{% endfor %}
【问题讨论】:
-
你试过了吗?结果哪里ok?
-
它工作正常。我想知道是否可以写得更好。
-
既然你问是因为你不喜欢你的代码中的某些东西。这是什么?就我个人而言,我不喜欢在翻译中包含太多 html 标签
标签: django translation django-templates django-i18n