Skip to content

Commit

Permalink
Used ngettext in a formsets error message
Browse files Browse the repository at this point in the history
Several languages will distinctly translate '%d or fewer forms'
depending on the variable.
  • Loading branch information
claudep committed May 4, 2013
1 parent d48b723 commit f9f0e8d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions django/forms/formsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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')
Expand Down Expand Up @@ -302,7 +302,9 @@ def full_clean(self):
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:
Expand Down

0 comments on commit f9f0e8d

Please sign in to comment.