Skip to content

Commit 152b0a6

Browse files
committed
Adds ugettext_lazy to more texts
Also adds a first german translation.
1 parent 0041530 commit 152b0a6

File tree

5 files changed

+115
-17
lines changed

5 files changed

+115
-17
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# SOME DESCRIPTIVE TITLE.
2+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3+
# This file is distributed under the same license as the PACKAGE package.
4+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5+
#
6+
#, fuzzy
7+
msgid ""
8+
msgstr ""
9+
"Project-Id-Version: PACKAGE VERSION\n"
10+
"Report-Msgid-Bugs-To: \n"
11+
"POT-Creation-Date: 2016-02-02 14:11+0100\n"
12+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14+
"Language-Team: LANGUAGE <[email protected]>\n"
15+
"Language: \n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=UTF-8\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
20+
21+
#: registration/serializers.py:54
22+
msgid "View is not defined, pass it as a context variable"
23+
msgstr "\"View\" ist nicht definiert, übergib es als Contextvariable"
24+
25+
#: registration/serializers.py:59
26+
msgid "Define adapter_class in view"
27+
msgstr "Definier \"adapter_class\" in view"
28+
29+
#: registration/serializers.py:78
30+
msgid "Define callback_url in view"
31+
msgstr "Definier \"callback_url\" in view"
32+
33+
#: registration/serializers.py:82
34+
msgid "Define client_class in view"
35+
msgstr "Definier \"client_class\" in view"
36+
37+
#: registration/serializers.py:102
38+
msgid "Incorrect input. access_token or code is required."
39+
msgstr "Falsche Eingabe. \"access_token\" oder \"code\" erforderlich."
40+
41+
#: registration/serializers.py:111
42+
msgid "Incorrect value"
43+
msgstr "Falscher Wert."
44+
45+
#: registration/serializers.py:140
46+
msgid "A user is already registered with this e-mail address."
47+
msgstr "Ein User mit dieser E-Mail Adresse ist schon registriert."
48+
49+
#: registration/serializers.py:148
50+
msgid "The two password fields didn't match."
51+
msgstr "Die beiden Passwörter sind nicht identisch."
52+
53+
#: registration/views.py:64
54+
msgid "ok"
55+
msgstr "Ok"
56+
57+
#: serializers.py:29
58+
msgid "Must include \"email\" and \"password\"."
59+
msgstr "Muss \"email\" und \"password\" enthalten."
60+
61+
#: serializers.py:40
62+
msgid "Must include \"username\" and \"password\"."
63+
msgstr "Muss \"username\" und \"password\" enthalten."
64+
65+
#: serializers.py:53
66+
msgid "Must include either \"username\" or \"email\" and \"password\"."
67+
msgstr "Muss entweder \"username\" oder \"email\" und password \"password\""
68+
69+
#: serializers.py:94
70+
msgid "User account is disabled."
71+
msgstr "Der Useraccount ist deaktiviert."
72+
73+
#: serializers.py:97
74+
msgid "Unable to log in with provided credentials."
75+
msgstr "Kann nicht mit den angegeben Zugangsdaten anmelden."
76+
77+
#: serializers.py:106
78+
msgid "E-mail is not verified."
79+
msgstr "E-Mail Adresse ist nicht verifiziert."
80+
81+
#: serializers.py:152
82+
msgid "Error"
83+
msgstr "Fehler"
84+
85+
#: views.py:71
86+
msgid "Successfully logged out."
87+
msgstr "Erfolgreich ausgeloggt."
88+
89+
#: views.py:111
90+
msgid "Password reset e-mail has been sent."
91+
msgstr "Die E-Mail zum Zurücksetzen des Passwortes wurde verschickt."
92+
93+
#: views.py:132
94+
msgid "Password has been reset with the new password."
95+
msgstr "Das Passwort wurde mit dem neuen Passwort ersetzt."
96+
97+
#: views.py:150
98+
msgid "New password has been saved."
99+
msgstr "Das neue Passwort wurde gespeichert."

rest_auth/registration/serializers.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django.http import HttpRequest
22
from django.conf import settings
3+
from django.utils.translation import ugettext_lazy as _
34

45
try:
56
from allauth.account import app_settings as allauth_settings
@@ -53,12 +54,12 @@ def validate(self, attrs):
5354

5455
if not view:
5556
raise serializers.ValidationError(
56-
'View is not defined, pass it as a context variable'
57+
_('View is not defined, pass it as a context variable')
5758
)
5859

5960
adapter_class = getattr(view, 'adapter_class', None)
6061
if not adapter_class:
61-
raise serializers.ValidationError('Define adapter_class in view')
62+
raise serializers.ValidationError(_('Define adapter_class in view'))
6263

6364
adapter = adapter_class()
6465
app = adapter.get_provider().get_app(request)
@@ -77,11 +78,11 @@ def validate(self, attrs):
7778

7879
if not self.callback_url:
7980
raise serializers.ValidationError(
80-
'Define callback_url in view'
81+
_('Define callback_url in view')
8182
)
8283
if not self.client_class:
8384
raise serializers.ValidationError(
84-
'Define client_class in view'
85+
_('Define client_class in view')
8586
)
8687

8788
code = attrs.get('code')
@@ -101,7 +102,7 @@ def validate(self, attrs):
101102
access_token = token['access_token']
102103

103104
else:
104-
raise serializers.ValidationError('Incorrect input. access_token or code is required.')
105+
raise serializers.ValidationError(_('Incorrect input. access_token or code is required.'))
105106

106107
token = adapter.parse_token({'access_token': access_token})
107108
token.app = app
@@ -110,7 +111,7 @@ def validate(self, attrs):
110111
login = self.get_social_login(adapter, app, token, access_token)
111112
complete_social_login(request, login)
112113
except HTTPError:
113-
raise serializers.ValidationError('Incorrect value')
114+
raise serializers.ValidationError(_('Incorrect value'))
114115

115116
if not login.is_existing:
116117
login.lookup()
@@ -139,15 +140,15 @@ def validate_email(self, email):
139140
if allauth_settings.UNIQUE_EMAIL:
140141
if email and email_address_exists(email):
141142
raise serializers.ValidationError(
142-
"A user is already registered with this e-mail address.")
143+
_("A user is already registered with this e-mail address."))
143144
return email
144145

145146
def validate_password1(self, password):
146147
return get_adapter().clean_password(password)
147148

148149
def validate(self, data):
149150
if data['password1'] != data['password2']:
150-
raise serializers.ValidationError("The two password fields didn't match.")
151+
raise serializers.ValidationError(_("The two password fields didn't match."))
151152
return data
152153

153154
def custom_signup(self, request, user):

rest_auth/registration/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def post(self, request, *args, **kwargs):
6161
self.kwargs['key'] = serializer.validated_data['key']
6262
confirmation = self.get_object()
6363
confirmation.confirm(self.request)
64-
return Response({'message': 'ok'}, status=status.HTTP_200_OK)
64+
return Response({'message': _('ok')}, status=status.HTTP_200_OK)
6565

6666

6767
class SocialLoginView(LoginView):

rest_auth/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def validate(self, attrs):
103103
if app_settings.EMAIL_VERIFICATION == app_settings.EmailVerificationMethod.MANDATORY:
104104
email_address = user.emailaddress_set.get(email=user.email)
105105
if not email_address.verified:
106-
raise serializers.ValidationError('E-mail is not verified.')
106+
raise serializers.ValidationError(_('E-mail is not verified.'))
107107

108108
attrs['user'] = user
109109
return attrs

rest_auth/views.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from django.contrib.auth import login, logout
22
from django.conf import settings
33
from django.core.exceptions import ObjectDoesNotExist
4+
from django.utils.translation import ugettext_lazy as _
45

56
from rest_framework import status
67
from rest_framework.views import APIView
@@ -69,12 +70,11 @@ def post(self, request):
6970

7071
logout(request)
7172

72-
return Response({"success": "Successfully logged out."},
73+
return Response({"success": _("Successfully logged out.")},
7374
status=status.HTTP_200_OK)
7475

7576

7677
class UserDetailsView(RetrieveUpdateAPIView):
77-
7878
"""
7979
Returns User's details in JSON format.
8080
@@ -111,13 +111,12 @@ def post(self, request, *args, **kwargs):
111111
serializer.save()
112112
# Return the success message with OK HTTP status
113113
return Response(
114-
{"success": "Password reset e-mail has been sent."},
114+
{"success": _("Password reset e-mail has been sent.")},
115115
status=status.HTTP_200_OK
116116
)
117117

118118

119119
class PasswordResetConfirmView(GenericAPIView):
120-
121120
"""
122121
Password reset e-mail link is confirmed, therefore this resets the user's password.
123122
@@ -133,11 +132,10 @@ def post(self, request):
133132
serializer = self.get_serializer(data=request.data)
134133
serializer.is_valid(raise_exception=True)
135134
serializer.save()
136-
return Response({"success": "Password has been reset with the new password."})
135+
return Response({"success": _("Password has been reset with the new password.")})
137136

138137

139138
class PasswordChangeView(GenericAPIView):
140-
141139
"""
142140
Calls Django Auth SetPasswordForm save method.
143141
@@ -152,4 +150,4 @@ def post(self, request):
152150
serializer = self.get_serializer(data=request.data)
153151
serializer.is_valid(raise_exception=True)
154152
serializer.save()
155-
return Response({"success": "New password has been saved."})
153+
return Response({"success": _("New password has been saved.")})

0 commit comments

Comments
 (0)