Skip to content

Commit d321227

Browse files
committed
ngettext is supported in Django 2.2
1 parent 09436f5 commit d321227

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

password_policies/forms/validators.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66

77
from django.core.exceptions import ValidationError
88
from django.utils.encoding import force_str, smart_str
9+
from django.utils.translation import ngettext
910

1011
try:
1112
from django.utils.translation import gettext_lazy as _
12-
from django.utils.translation import ngettext as ungettext
1313
except ImportError:
1414
# Before in Django 3.0
1515
from django.utils.translation import ugettext_lazy as _
16-
from django.utils.translation import ungettext
1716

1817
from password_policies.conf import settings
1918

@@ -197,7 +196,7 @@ def __call__(self, value):
197196
if len(list(group)) > self.get_max_count():
198197
consecutive_found = True
199198
if consecutive_found:
200-
msg = ungettext(
199+
msg = ngettext(
201200
"The new password contains consecutive"
202201
" characters. Only %(count)d consecutive character"
203202
" is allowed.",
@@ -431,7 +430,7 @@ def get_error_message(self):
431430
"""
432431
Returns this validator's error message."""
433432
msg = (
434-
ungettext(
433+
ngettext(
435434
"The new password must contain %d or more letter.",
436435
"The new password must contain %d or more letters.",
437436
self.get_min_count(),
@@ -472,7 +471,7 @@ def get_error_message(self):
472471
"""
473472
Returns this validator's error message."""
474473
msg = (
475-
ungettext(
474+
ngettext(
476475
"The new password must contain %d or more lowercase letter.",
477476
"The new password must contain %d or more lowercase letters.",
478477
self.get_min_count(),
@@ -514,7 +513,7 @@ def get_error_message(self):
514513
"""
515514
Returns this validator's error message."""
516515
msg = (
517-
ungettext(
516+
ngettext(
518517
"The new password must contain %d or more uppercase letter.",
519518
"The new password must contain %d or more uppercase letters.",
520519
self.get_min_count(),
@@ -598,7 +597,7 @@ def get_error_message(self):
598597
"""
599598
Returns this validator's error message."""
600599
msg = (
601-
ungettext(
600+
ngettext(
602601
"The new password must contain %d or more number.",
603602
"The new password must contain %d or more numbers.",
604603
self.get_min_count(),
@@ -670,7 +669,7 @@ def get_error_message(self):
670669
"""
671670
Returns this validator's error message."""
672671
msg = (
673-
ungettext(
672+
ngettext(
674673
"The new password must contain %d or more symbol.",
675674
"The new password must contain %d or more symbols.",
676675
self.get_min_count(),

0 commit comments

Comments
 (0)