diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index 1997bd5..a825141 100644
a
|
b
|
from django.contrib.sites.models import Site
|
4 | 4 | from django.template import Context, loader |
5 | 5 | from django.core import validators |
6 | 6 | from django import newforms as forms |
7 | | from django.utils.translation import ugettext as _ |
| 7 | from django.utils.translation import ugettext_lazy as _, ugettext |
8 | 8 | |
9 | 9 | class UserCreationForm(forms.ModelForm): |
10 | 10 | """ |
… |
… |
class UserCreationForm(forms.ModelForm):
|
26 | 26 | User.objects.get(username=username) |
27 | 27 | except User.DoesNotExist: |
28 | 28 | return username |
29 | | raise forms.ValidationError(_("A user with that username already exists.")) |
| 29 | raise forms.ValidationError(ugettext("A user with that username already exists.")) |
30 | 30 | |
31 | 31 | def clean_password2(self): |
32 | 32 | password1 = self.cleaned_data["password1"] |
33 | 33 | password2 = self.cleaned_data["password2"] |
34 | 34 | if password1 != password2: |
35 | | raise forms.ValidationError(_("The two password fields didn't match.")) |
| 35 | raise forms.ValidationError(ugettext("The two password fields didn't match.")) |
36 | 36 | return password2 |
37 | 37 | |
38 | 38 | def save(self, commit=True): |
… |
… |
class AuthenticationForm(forms.Form):
|
68 | 68 | if username and password: |
69 | 69 | self.user_cache = authenticate(username=username, password=password) |
70 | 70 | if self.user_cache is None: |
71 | | raise forms.ValidationError(_("Please enter a correct username and password. Note that both fields are case-sensitive.")) |
| 71 | raise forms.ValidationError(ugettext("Please enter a correct username and password. Note that both fields are case-sensitive.")) |
72 | 72 | elif not self.user_cache.is_active: |
73 | | raise forms.ValidationError(_("This account is inactive.")) |
| 73 | raise forms.ValidationError(ugettext("This account is inactive.")) |
74 | 74 | |
75 | 75 | # TODO: determine whether this should move to its own method. |
76 | 76 | if self.request: |
77 | 77 | if not self.request.session.test_cookie_worked(): |
78 | | raise forms.ValidationError(_("Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in.")) |
| 78 | raise forms.ValidationError(ugettext("Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in.")) |
79 | 79 | |
80 | 80 | return self.cleaned_data |
81 | 81 | |
… |
… |
class PasswordResetForm(forms.Form):
|
97 | 97 | email = self.cleaned_data["email"] |
98 | 98 | self.users_cache = User.objects.filter(email__iexact=email) |
99 | 99 | if len(self.users_cache) == 0: |
100 | | raise forms.ValidationError(_("That e-mail address doesn't have an associated user account. Are you sure you've registered?")) |
| 100 | raise forms.ValidationError(ugettext("That e-mail address doesn't have an associated user account. Are you sure you've registered?")) |
101 | 101 | |
102 | 102 | def save(self, domain_override=None, email_template_name='registration/password_reset_email.html'): |
103 | 103 | """ |
… |
… |
class PasswordResetForm(forms.Form):
|
122 | 122 | 'site_name': site_name, |
123 | 123 | 'user': user, |
124 | 124 | } |
125 | | send_mail(_("Password reset on %s") % site_name, |
| 125 | send_mail(ugettext("Password reset on %s") % site_name, |
126 | 126 | t.render(Context(c)), None, [user.email]) |
127 | 127 | |
128 | 128 | class PasswordChangeForm(forms.Form): |
… |
… |
class PasswordChangeForm(forms.Form):
|
143 | 143 | """ |
144 | 144 | old_password = self.cleaned_data["old_password"] |
145 | 145 | if not self.user.check_password(old_password): |
146 | | raise forms.ValidationError(_("Your old password was entered incorrectly. Please enter it again.")) |
| 146 | raise forms.ValidationError(ugettext("Your old password was entered incorrectly. Please enter it again.")) |
147 | 147 | return old_password |
148 | 148 | |
149 | 149 | def clean_new_password2(self): |
… |
… |
class PasswordChangeForm(forms.Form):
|
151 | 151 | password2 = self.cleaned_data.get('new_password2') |
152 | 152 | if password1 and password2: |
153 | 153 | if password1 != password2: |
154 | | raise forms.ValidationError(_("The two password fields didn't match.")) |
| 154 | raise forms.ValidationError(ugettext("The two password fields didn't match.")) |
155 | 155 | return password2 |
156 | 156 | |
157 | 157 | def save(self, commit=True): |
… |
… |
class AdminPasswordChangeForm(forms.Form):
|
176 | 176 | password2 = self.cleaned_data.get('password2') |
177 | 177 | if password1 and password2: |
178 | 178 | if password1 != password2: |
179 | | raise forms.ValidationError(_("The two password fields didn't match.")) |
| 179 | raise forms.ValidationError(ugettext("The two password fields didn't match.")) |
180 | 180 | return password2 |
181 | 181 | |
182 | 182 | def save(self, commit=True): |