Skip to content

Commit 9911257

Browse files
authored
Merge pull request #2115 from wger-project/fix/use-gettext-lazy
Properly translate the strings
2 parents 0cf7ce9 + 7ce1a03 commit 9911257

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

wger/core/forms.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
widgets,
3535
)
3636
from django.utils.translation import gettext as _
37+
from django.utils.translation import gettext_lazy
3738

3839
# Third Party
3940
from crispy_forms.helper import FormHelper
@@ -75,7 +76,7 @@ class UserLoginForm(AuthenticationForm):
7576
authenticate_on_clean = True
7677

7778
def __init__(self, authenticate_on_clean=True, *args, **kwargs):
78-
super(UserLoginForm, self).__init__(*args, **kwargs)
79+
super().__init__(*args, **kwargs)
7980

8081
# Apply custom password widget
8182
self.fields['password'].widget = PasswordInputWithToggle()
@@ -122,15 +123,15 @@ def authenticate(self, request):
122123

123124

124125
class UserPreferencesForm(forms.ModelForm):
125-
first_name = forms.CharField(label=_('First name'), required=False)
126-
last_name = forms.CharField(label=_('Last name'), required=False)
126+
first_name = forms.CharField(label=gettext_lazy('First name'), required=False)
127+
last_name = forms.CharField(label=gettext_lazy('Last name'), required=False)
127128
email = EmailField(
128-
label=_('Email'),
129-
help_text=_('Used for password resets and, optionally, e-mail reminders.'),
129+
label=gettext_lazy('Email'),
130+
help_text=gettext_lazy('Used for password resets and, optionally, e-mail reminders.'),
130131
required=False,
131132
)
132133
birthdate = forms.DateField(
133-
label=_('Date of Birth'),
134+
label=gettext_lazy('Date of Birth'),
134135
required=False,
135136
widget=forms.DateInput(
136137
attrs={
@@ -202,8 +203,8 @@ def __init__(self, *args, **kwargs):
202203

203204
class UserEmailForm(forms.ModelForm):
204205
email = EmailField(
205-
label=_('Email'),
206-
help_text=_('Used for password resets and, optionally, email reminders.'),
206+
label=gettext_lazy('Email'),
207+
help_text=gettext_lazy('Used for password resets and, optionally, email reminders.'),
207208
required=False,
208209
)
209210

@@ -253,14 +254,14 @@ class PasswordConfirmationForm(Form):
253254
"""
254255

255256
password = CharField(
256-
label=_('Password'),
257+
label=gettext_lazy('Password'),
257258
widget=PasswordInputWithToggle,
258-
help_text=_('Please enter your current password.'),
259+
help_text=gettext_lazy('Please enter your current password.'),
259260
)
260261

261262
def __init__(self, user, data=None):
262263
self.user = user
263-
super(PasswordConfirmationForm, self).__init__(data=data)
264+
super().__init__(data=data)
264265
self.helper = FormHelper()
265266
self.helper.layout = Layout(
266267
'password',
@@ -285,11 +286,11 @@ class RegistrationForm(UserCreationForm, UserEmailForm):
285286
captcha = ReCaptchaField(
286287
widget=ReCaptchaV3,
287288
label='reCaptcha',
288-
help_text=_('The form is secured with reCAPTCHA'),
289+
help_text=gettext_lazy('The form is secured with reCAPTCHA'),
289290
)
290291

291292
def __init__(self, *args, **kwargs):
292-
super(RegistrationForm, self).__init__(*args, **kwargs)
293+
super().__init__(*args, **kwargs)
293294

294295
# Apply custom password widgets
295296
self.fields['password1'].widget = PasswordInputWithToggle()
@@ -316,7 +317,7 @@ class RegistrationFormNoCaptcha(UserCreationForm, UserEmailForm):
316317
"""
317318

318319
def __init__(self, *args, **kwargs):
319-
super(RegistrationFormNoCaptcha, self).__init__(*args, **kwargs)
320+
super().__init__(*args, **kwargs)
320321

321322
# Apply custom password widgets
322323
self.fields['password1'].widget = PasswordInputWithToggle()
@@ -347,17 +348,17 @@ class FeedbackRegisteredForm(forms.Form):
347348
contact = forms.CharField(
348349
max_length=50,
349350
min_length=10,
350-
label=_('Contact'),
351-
help_text=_('Some way of answering you (e-mail, etc.)'),
351+
label=gettext_lazy('Contact'),
352+
help_text=gettext_lazy('Some way of answering you (e-mail, etc.)'),
352353
required=False,
353354
)
354355

355356
comment = forms.CharField(
356357
max_length=500,
357358
min_length=10,
358359
widget=widgets.Textarea,
359-
label=_('Comment'),
360-
help_text=_('What do you want to say?'),
360+
label=gettext_lazy('Comment'),
361+
help_text=gettext_lazy('What do you want to say?'),
361362
required=True,
362363
)
363364

@@ -370,5 +371,5 @@ class FeedbackAnonymousForm(FeedbackRegisteredForm):
370371
captcha = ReCaptchaField(
371372
widget=ReCaptchaV3,
372373
label='reCaptcha',
373-
help_text=_('The form is secured with reCAPTCHA'),
374+
help_text=gettext_lazy('The form is secured with reCAPTCHA'),
374375
)

0 commit comments

Comments
 (0)