Updated PLANS.md, AGENTS.md, and arabic-localization.md to reflect the “foundations now, full translations later” approach and marked progress accordingly.
Implemented localization foundations across backend and frontend (locale settings/middleware, preferred language, i18n wiring, RTL support, minimal Arabic UI strings, Accept-Language). Added targeted backend and frontend tests plus a risks note for pending full translation coverage.
This commit is contained in:
@@ -2,6 +2,7 @@ from django.contrib.auth import get_user_model
|
||||
from django.shortcuts import get_object_or_404
|
||||
from rest_framework import generics, permissions, status
|
||||
from rest_framework.response import Response
|
||||
from django.utils.translation import gettext as _
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework_simplejwt.tokens import RefreshToken
|
||||
|
||||
@@ -71,14 +72,14 @@ class OTPVerifyView(APIView):
|
||||
data = serializer.validated_data
|
||||
otp = get_object_or_404(PhoneOTP, id=data["request_id"])
|
||||
if not verify_otp(otp, data["code"]):
|
||||
return Response({"detail": "Invalid or expired code"}, status=status.HTTP_400_BAD_REQUEST)
|
||||
return Response({"detail": _("Invalid or expired code")}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
user = User.objects.filter(phone_number=otp.phone_number).first()
|
||||
if user and not user.is_phone_verified:
|
||||
user.is_phone_verified = True
|
||||
user.save(update_fields=["is_phone_verified"])
|
||||
|
||||
return Response({"detail": "Phone verified"}, status=status.HTTP_200_OK)
|
||||
return Response({"detail": _("Phone verified")}, status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
class PhoneAuthRequestView(APIView):
|
||||
@@ -95,7 +96,7 @@ class PhoneAuthRequestView(APIView):
|
||||
if not user:
|
||||
if email and User.objects.filter(email=email).exists():
|
||||
return Response(
|
||||
{"detail": "Email already in use."},
|
||||
{"detail": _("Email already in use.")},
|
||||
status=status.HTTP_400_BAD_REQUEST,
|
||||
)
|
||||
user = User.objects.create_user(
|
||||
@@ -134,11 +135,11 @@ class PhoneAuthVerifyView(APIView):
|
||||
data = serializer.validated_data
|
||||
otp = get_object_or_404(PhoneOTP, id=data["request_id"])
|
||||
if not verify_otp(otp, data["code"]):
|
||||
return Response({"detail": "Invalid or expired code"}, status=status.HTTP_400_BAD_REQUEST)
|
||||
return Response({"detail": _("Invalid or expired code")}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
user = User.objects.filter(phone_number=otp.phone_number).first()
|
||||
if not user:
|
||||
return Response({"detail": "User not found"}, status=status.HTTP_404_NOT_FOUND)
|
||||
return Response({"detail": _("User not found")}, status=status.HTTP_404_NOT_FOUND)
|
||||
|
||||
if not user.is_phone_verified:
|
||||
user.is_phone_verified = True
|
||||
@@ -160,6 +161,6 @@ class SocialLoginPlaceholderView(APIView):
|
||||
|
||||
def post(self, request, provider):
|
||||
return Response(
|
||||
{"detail": "Social login not configured yet. Add OAuth provider config."},
|
||||
{"detail": _("Social login not configured yet. Add OAuth provider config.")},
|
||||
status=status.HTTP_501_NOT_IMPLEMENTED,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user