Hi all

Django 1.3's blocktrans tag is documented as still supporting 1.2's
more verbose syntax. However, if you attempt a plural translation, it
barfs. More importantly, it rejects a format that 1.2 accepts, and
accepts a format that 1.2 rejects.

This format is rejected by 1.2 and accepted by 1.3:

tmpl2 = """
{% load i18n %}
{% blocktrans with items as stuff and count items|length|add:"-3" as
more_count %}
{{ more_count }} more
{% plural %}
{{ more_count }} more
{% endblocktrans %}
"""

This format is accepted by 1.2 and rejected by 1.3:

tmpl3 = """
{% load i18n %}
{% blocktrans count items|length|add:"-3" as more_count and items as stuff %}
{{ more_count }} more
{% plural %}
{{ more_count }} more
{% endblocktrans %}
"""

The 1.3 documentation states that "The previous more verbose format is
still supported", without going into details of what that format is.
This probably requires either a fix to be more 1.2 compatible, or a
documentation note in 1.3 noting the differences in formats that it
will parse and  an update to the 1.3 backwards incompatibilities
noting this difference.

Cheers

Tom


Full transcripts below:

>>> from django.template import Template, Context, TemplateSyntaxError
>>> import django
>>> django.VERSION
(1, 2, 7, 'final', 0)
>>> try:
...     Template(tmpl2).render(Context({'items':[1,2,3,4,5,6]}))
... except TemplateSyntaxError, e:
...     print e
...
variable bindings in 'blocktrans' must be 'with value as variable'
>>> try:
...     Template(tmpl3).render(Context({'items':[1,2,3,4,5,6]}))
... except TemplateSyntaxError, e:
...     print e
...
u'\n\n\n3 more\n\n'


>>> from django.template import Template, Context, TemplateSyntaxError
>>> import django
>>> django.VERSION
(1, 3, 1, 'final', 0)
>>> try:
...     Template(tmpl2).render(Context({'items':[1,2,3,4,5,6]}))
... except TemplateSyntaxError, e:
...     print e
...
u'\n\n\n3 more\n\n'
>>> try:
...     Template(tmpl3).render(Context({'items':[1,2,3,4,5,6]}))
... except TemplateSyntaxError, e:
...     print e
...
"count" in u'blocktrans' tag expected exactly one keyword argument.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to