4

{% blocktrans %}with " with " と " count " を同時に使用することはできますか?

ドキュメントでは、次を使用して個別にのみ説明しています。

{% blocktrans with foo|filter as bar and baz|filter as boo %}
{% blocktrans count var|length as count %}


ある変数の値を出力する必要があり、翻訳は別の変数に依存します。次のコードを試しました:

{% blocktrans count cnt as count with cnt|make_text_from_count as text_count %}
    and other {{ text_count }} city
{% plural %}
    and other {{ text_count }} cities
{% endblocktrans %}

変数の値を表示しますが、text_countテキストは翻訳しません。


Python 2.6.6、ジャンゴ 1.3、ジャンゴ テンプレート。

4

2 に答える 2

1

http://docs.djangoproject.com/en/dev/topics/i18n/internationalization/#blocktrans-template-tag

{% blocktrans with text_count=cnt|make_text_from_count count cnt=cnt %}
    and another city
{% plural %}
    and other {{ text_count }} cities
{% endblocktrans %}
于 2011-03-24T08:41:11.297 に答える