From f9f0e8da4d1107575ebee07a808cd254ac3d9dc0 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 4 May 2013 10:08:38 +0200 Subject: [PATCH] Used ngettext in a formsets error message Several languages will distinctly translate '%d or fewer forms' depending on the variable. --- django/forms/formsets.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/django/forms/formsets.py b/django/forms/formsets.py index 2ab197dee2..2bd11d9f53 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -9,7 +9,7 @@ from django.utils.encoding import python_2_unicode_compatible from django.utils.safestring import mark_safe from django.utils import six from django.utils.six.moves import xrange -from django.utils.translation import ugettext as _ +from django.utils.translation import ungettext, ugettext as _ __all__ = ('BaseFormSet', 'all_valid') @@ -302,7 +302,9 @@ class BaseFormSet(object): try: if (self.validate_max and self.total_form_count() > self.max_num) or \ self.management_form.cleaned_data[TOTAL_FORM_COUNT] > self.absolute_max: - raise ValidationError(_("Please submit %s or fewer forms." % self.max_num)) + raise ValidationError(ungettext( + "Please submit %d or fewer forms.", + "Please submit %d or fewer forms.", self.max_num) % self.max_num) # Give self.clean() a chance to do cross-form validation. self.clean() except ValidationError as e: