From 5171f56faeb9ec27153c7e7319c96d3fba774ea5 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 10 Oct 2015 15:12:55 +0200 Subject: [PATCH] Pluralized translatable strings in password_validation.py Forward port of 86dc4889f from master. --- .../auth/locale/en/LC_MESSAGES/django.po | 30 +++++++++++-------- django/contrib/auth/password_validation.py | 14 +++++++-- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/django/contrib/auth/locale/en/LC_MESSAGES/django.po b/django/contrib/auth/locale/en/LC_MESSAGES/django.po index fdfde63b77..aa69218cc2 100644 --- a/django/contrib/auth/locale/en/LC_MESSAGES/django.po +++ b/django/contrib/auth/locale/en/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: Django\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-10-09 17:42+0200\n" +"POT-Creation-Date: 2015-10-10 15:10+0200\n" "PO-Revision-Date: 2010-05-13 15:35+0200\n" "Last-Translator: Django team\n" "Language-Team: English \n" @@ -262,40 +262,46 @@ msgstr "" msgid "users" msgstr "" -#: contrib/auth/password_validation.py:100 +#: contrib/auth/password_validation.py:101 #, python-format msgid "" "This password is too short. It must contain at least %(min_length)d " +"character." +msgid_plural "" +"This password is too short. It must contain at least %(min_length)d " "characters." -msgstr "" +msgstr[0] "" +msgstr[1] "" -#: contrib/auth/password_validation.py:106 +#: contrib/auth/password_validation.py:111 #, python-format -msgid "Your password must contain at least %(min_length)d characters." -msgstr "" +msgid "Your password must contain at least %(min_length)d character." +msgid_plural "Your password must contain at least %(min_length)d characters." +msgstr[0] "" +msgstr[1] "" -#: contrib/auth/password_validation.py:139 +#: contrib/auth/password_validation.py:147 #, python-format msgid "The password is too similar to the %(verbose_name)s." msgstr "" -#: contrib/auth/password_validation.py:145 +#: contrib/auth/password_validation.py:153 msgid "Your password can't be too similar to your other personal information." msgstr "" -#: contrib/auth/password_validation.py:172 +#: contrib/auth/password_validation.py:180 msgid "This password is too common." msgstr "" -#: contrib/auth/password_validation.py:177 +#: contrib/auth/password_validation.py:185 msgid "Your password can't be a commonly used password." msgstr "" -#: contrib/auth/password_validation.py:187 +#: contrib/auth/password_validation.py:195 msgid "This password is entirely numeric." msgstr "" -#: contrib/auth/password_validation.py:192 +#: contrib/auth/password_validation.py:200 msgid "Your password can't be entirely numeric." msgstr "" diff --git a/django/contrib/auth/password_validation.py b/django/contrib/auth/password_validation.py index 332d76c845..2af5202207 100644 --- a/django/contrib/auth/password_validation.py +++ b/django/contrib/auth/password_validation.py @@ -13,7 +13,7 @@ from django.utils.encoding import force_text from django.utils.html import format_html from django.utils.module_loading import import_string from django.utils.six import string_types -from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext as _, ungettext @lru_cache.lru_cache(maxsize=None) @@ -97,13 +97,21 @@ class MinimumLengthValidator(object): def validate(self, password, user=None): if len(password) < self.min_length: raise ValidationError( - _("This password is too short. It must contain at least %(min_length)d characters."), + ungettext( + "This password is too short. It must contain at least %(min_length)d character.", + "This password is too short. It must contain at least %(min_length)d characters.", + self.min_length + ), code='password_too_short', params={'min_length': self.min_length}, ) def get_help_text(self): - return _("Your password must contain at least %(min_length)d characters.") % {'min_length': self.min_length} + return ungettext( + "Your password must contain at least %(min_length)d character.", + "Your password must contain at least %(min_length)d characters.", + self.min_length + ) % {'min_length': self.min_length} class UserAttributeSimilarityValidator(object):