#37202: MinimumLengthValidator.get_error_message has a bug that breaks translation
----------------------------------------+--------------------------
Reporter: meng | Owner: (none)
Type: Bug | Status: assigned
Component: contrib.auth | Version: 5.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+--------------------------
Hello,
The get_error_message method of the MinimumLengthValidator class in
Django's auth password_validation.py file has a bug that prevents
translations from working correctly.
The problem code is:
{{{
class MinimumLengthValidator:
...
def get_error_message(self):
return (
ngettext(
"This password is too short. It must contain at least %d
character.",
"This password is too short. It must contain at least %d
characters.",
self.min_length,
)
% self.min_length
)
}}}
The correct code should be:
{{{
class MinimumLengthValidator:
...
def get_error_message(self):
return (
ngettext(
"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,
)
% {"min_length": self.min_length}
)
}}}
--
Ticket URL: <
https://code.djangoproject.com/ticket/37202>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.