Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#13568 closed (fixed)

KeyError raised in template rendering when the number of placeholders differs between singular and plural

Reported by: deltoide Owned by: deltoide
Component: Internationalization Version: dev
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Here is a simple example to reproduce the bug:

template file: index.html

{% load i18n %}

{% blocktrans with myextra_field as extra_field and myamount as amount count myyears as years %}
That will cost $ {{ amount }} per year. {{ extra_field }}
{% plural %}
That will cost $ {{ amount }} per {{ years }} years.
{% endblocktrans %}

views.py:

from django.http import HttpResponse
from django.template import Context, loader
from django.http import HttpResponse
def index(request):
    t = loader.get_template('index.html')
    c = Context({
          'myamount' : 10,
          'myyears' : 1,
          'myextra_field' : 2,
    })
    return HttpResponse(t.render(c))

Attachments (2)

i18n_13568.diff (1.8 KB ) - added by deltoide 14 years ago.
Fix + regression test
i18n_13568.2.diff (1.8 KB ) - added by deltoide 14 years ago.
Fix + regression test (with link to this bug 13568)

Download all attachments as: .zip

Change History (8)

comment:1 by deltoide, 14 years ago

Owner: changed from nobody to deltoide

by deltoide, 14 years ago

Attachment: i18n_13568.diff added

Fix + regression test

comment:2 by deltoide, 14 years ago

Has patch: set

by deltoide, 14 years ago

Attachment: i18n_13568.2.diff added

Fix + regression test (with link to this bug 13568)

comment:3 by Russell Keith-Magee, 14 years ago

milestone: 1.3
Triage Stage: UnreviewedReady for checkin

comment:4 by Jannis Leidel, 14 years ago

Resolution: fixed
Status: newclosed

(In [13967]) Fixed #13568 -- Fixed the blocktrans tag to not raise a KeyError if the number of variables in the singular and the plural block differ. Thanks, deloide.

comment:5 by Jannis Leidel, 14 years ago

(In [13973]) [1.2.X] Fixed #13568 -- Fixed the blocktrans tag to not raise a KeyError if the number of variables in the singular and the plural block differ. Thanks, deloide.

Backport from trunk (r13967).

comment:6 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top