views:

244

answers:

1

According to this section in the Django docs I should use {% blocktrans %} for cases where I need to translate pluralizations. However, with an example like the following, isn't there something more convenient I can do?

{% blocktrans count video.views.count as views %}
The video has been viewed <span>{{ views }}</span> time
{% plural %}
The video has been viewed <span>{{ views }}</span> times
{% endblocktrans %}

I tried to do the following:

{% blocktrans %}time{% plural %}times{% endblocktrans %}

But it threw TemplateSyntaxError: 'blocktrans' doesn't allow other block tags (seen u'plural') inside it

+2  A: 

You forgot the count variable as variable_name in the blocktrans tag

The value of that variable will be used to detect if it's plural or not

naw
Ah now I see :) I still feel like there should be a more convenient way than this though:{% trans "The video has been viewed" %} <span>{{ video.views.count }}</span>{% blocktrans count video.views.count as views %}time{% plural %}times{% endblocktrans %}
Saosin