Skip to content

Commit

Permalink
ngettext is supported in Django 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemanger committed Jul 29, 2024
1 parent 09436f5 commit d321227
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions password_policies/forms/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@

from django.core.exceptions import ValidationError
from django.utils.encoding import force_str, smart_str
from django.utils.translation import ngettext

try:
from django.utils.translation import gettext_lazy as _
from django.utils.translation import ngettext as ungettext
except ImportError:
# Before in Django 3.0
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext

from password_policies.conf import settings

Expand Down Expand Up @@ -197,7 +196,7 @@ def __call__(self, value):
if len(list(group)) > self.get_max_count():
consecutive_found = True
if consecutive_found:
msg = ungettext(
msg = ngettext(
"The new password contains consecutive"
" characters. Only %(count)d consecutive character"
" is allowed.",
Expand Down Expand Up @@ -431,7 +430,7 @@ def get_error_message(self):
"""
Returns this validator's error message."""
msg = (
ungettext(
ngettext(
"The new password must contain %d or more letter.",
"The new password must contain %d or more letters.",
self.get_min_count(),
Expand Down Expand Up @@ -472,7 +471,7 @@ def get_error_message(self):
"""
Returns this validator's error message."""
msg = (
ungettext(
ngettext(
"The new password must contain %d or more lowercase letter.",
"The new password must contain %d or more lowercase letters.",
self.get_min_count(),
Expand Down Expand Up @@ -514,7 +513,7 @@ def get_error_message(self):
"""
Returns this validator's error message."""
msg = (
ungettext(
ngettext(
"The new password must contain %d or more uppercase letter.",
"The new password must contain %d or more uppercase letters.",
self.get_min_count(),
Expand Down Expand Up @@ -598,7 +597,7 @@ def get_error_message(self):
"""
Returns this validator's error message."""
msg = (
ungettext(
ngettext(
"The new password must contain %d or more number.",
"The new password must contain %d or more numbers.",
self.get_min_count(),
Expand Down Expand Up @@ -670,7 +669,7 @@ def get_error_message(self):
"""
Returns this validator's error message."""
msg = (
ungettext(
ngettext(
"The new password must contain %d or more symbol.",
"The new password must contain %d or more symbols.",
self.get_min_count(),
Expand Down

0 comments on commit d321227

Please sign in to comment.