import os import re import json # Pre-defined mapping of English keys to standard Arabic translations. # These represent the clean keys that were accidentally removed. ARABIC_TRANS = { "1 Passenger": "راكب واحد", "2 Passengers": "راكبين", "3 Passengers": "٣ ركاب", "4 Passengers": "٤ ركاب", "2. Attach Recorded Audio (Optional)": "٢. إرفاق تسجيل صوتي (اختياري)", "Account": "الحساب", "Actions": "الإجراءات", "Active Users": "المستخدمين النشطين", "Add a Stop": "إضافة نقطة توقف", "Add a new waypoint stop": "إضافة نقطة توقف جديدة", "After this period\\nYou can\\'t cancel!": "بعد هالوقت\\nما فيك تكنسل!", "Age is": "العمر", "Alert": "تنبيه", "An OTP has been sent to your number.": "تم إرسال كود التأكيد لرقمك.", "An error occurred": "حدث خطأ", "Appearance": "المظهر", "Are you sure you want to delete this file?": "متأكد بدك تحذف هالملف؟", "Are you sure you want to logout?": "متأكد بدك تسجل خروج؟", "Arrived": "وصلنا", "Audio Recording": "تسجيل صوتي", "Call": "اتصال", "Call Support": "اتصل بالدعم", "Call left": "مكالمات متبقية", "Change Photo": "تغيير الصورة", "Choose from Gallery": "اختر من المعرض", "Choose from contact": "اختر من جهات الاتصال", "Click to track the trip": "اضغط لتتبع المشوار", "Close panel": "إغلاق اللوحة", "Coming": "جايين", "Complete Payment": "إتمام الدفع", "Confirm Cancellation": "تأكيد الإلغاء", "Confirm Pickup Location": "تأكيد موقع الانطلاق", "Connection failed. Please try again.": "فشل الاتصال. جرب مرة تانية.", "Could not create ride. Please try again.": "ما قدرنا نعمل مشوار. جرب مرة تانية.", "Crop Photo": "قص الصورة", "Dark Mode": "الوضع الليلي", "Delete": "حذف", "Delete Account": "حذف الحساب", "Delete All": "حذف الكل", "Delete All Recordings?": "حذف كل التسجيلات؟", "Delete Recording?": "حذف التسجيل؟", "Destination Set": "تم تحديد الوجهة", "Distance": "المسافة", "Double tap to open search or enter destination": "اضغط مرتين لتفتح البحث أو تدخل الوجهة", "Double tap to set or change this waypoint on the map": "اضغط مرتين لتحديد أو تغيير هالنقطة عالخريطة", "Drawing route on map...": "عم نرسم الطريق عالخريطة...", "Driver Phone": "رقم الكابتن", "Driver is Going To You": "الكابتن جاي لعندك", "Emergency Mode Triggered": "تم تفعيل وضع الطوارئ", "Emergency SOS": "طوارئ SOS", "Enter the 5-digit code": "أدخل الكود المكون من ٥ أرقام", "Enter your City": "أدخل مدينتك", "Enter your Password": "أدخل كلمة السر", "Failed to book trip: $e": "فشل حجز المشوار", "Failed to get location": "فشل جلب الموقع", "Failed to initiate payment. Please try again.": "فشل بدء الدفع. جرب مرة تانية.", "Failed to send OTP": "فشل إرسال كود التأكيد", "Failed to upload photo": "فشل رفع الصورة", "Finished": "انتهى", "Fixed Price": "سعر ثابت", "General": "عام", "Grant": "منح الإذن", "Have a Promo Code?": "معك كود خصم؟", "Hello! I\\'m inviting you to try Intaleq.": "أهلاً! بدعيك لتجربة تطبيق انطلق.", "Hi ,I Arrive your site": "مرحباً، وصلت لموقعك", "Hi, Where to": "مرحباً، لوين؟", "Home": "الرئيسية", "I am currently located at": "أنا حالياً موجود بـ", "I'm Safe": "أنا بأمان", "If you need to reach me, please contact the driver directly at": "إذا بدك تتواصل معي، حاكي الكابتن مباشرة على", "Image Upload Failed": "فشل رفع الصورة", "Intaleq Passenger": "راكب انطلق", "Invite": "دعوة", "Join a channel": "انضم للقناة", "Last Name": "الاسم الأخير", "Leave a detailed comment (Optional)": "اترك تعليق تفصيلي (اختياري)", "Light Mode": "الوضع الفاتح", "Listen": "استماع", "Location": "الموقع", "Location Received": "تم استلام الموقع", "Logout": "تسجيل خروج", "Map Error": "خطأ بالخريطة", "Message": "رسالة", "Move map to select destination": "حرك الخريطة لتحديد الوجهة", "Move map to set start location": "حرك الخريطة لتحديد نقطة البداية", "Move map to set stop": "حرك الخريطة لتحديد التوقف", "Move map to your home location": "حرك الخريطة لموقع البيت", "Move map to your pickup point": "حرك الخريطة لموقع الانطلاق", "Move map to your work location": "حرك الخريطة لموقع الشغل", "N/A": "غير متاح", "No Notifications": "ما في إشعارات", "No Recordings Found": "ما في تسجيلات", "No Rides now!": "ما في مشاوير حالياً!", "No contacts available": "ما في جهات اتصال", "No i want": "لا بدي", "No notification data found.": "ما في بيانات للإشعار.", "No routes available for this destination.": "ما في طرق لهالوجهة.", "No user found": "ما في مستخدم", "No,I want": "لا، بدي", "No.Iwant Cancel Trip.": "لا. بدي كنسل المشوار.", "Now move the map to your pickup point": "الآن حرك الخريطة لمكان انطلاقك", "Now set the pickup point for the other person": "الآن حدد مكان الانطلاق للشخص التاني", "On Trip": "بالمشوار", "Open": "فتح", "Open destination search": "فتح بحث الوجهة", "Open in Google Maps": "فتح بخرائط جوجل", "Order VIP Canceld": "انلغى طلب VIP", "Passenger": "الراكب", "Passenger cancel order": "الراكب كنسل الطلب", "Pay by MTN Wallet": "الدفع بمحفظة سيريتل كاش", "Pay by Sham Cash": "الدفع بشام كاش", "Pay by Syriatel Wallet": "الدفع بمحفظة سيريتل كاش", "Pay with PayPal": "الدفع بـ PayPal", "Phone": "الموبايل", "Phone Number": "رقم الموبايل", "Phone Number Check": "فحص رقم الموبايل", "Phone number seems too short": "رقم الموبايل قصير كتير", "Phone verified. Please complete registration.": "تأكد الرقم. يرجى إتمام التسجيل.", "Pick destination on map": "اختر الوجهة عالخريطة", "Pick location on map": "اختر الموقع عالخريطة", "Pick on map": "اختر عالخريطة", "Pick start point on map": "اختر نقطة البداية عالخريطة", "Plan Your Route": "خطط مسارك", "Please add contacts to your phone.": "يرجى إضافة أسماء لجوالك.", "Please check your internet and try again.": "تأكد من النت وجرب مرة تانية.", "Please enter a valid email.": "أدخل إيميل صحيح.", "Please enter a valid phone number.": "أدخل رقم موبايل صحيح.", "Please enter the number without the leading 0": "أدخل الرقم بدون 0 بالبداية", "Please enter your phone number": "أدخل رقم موبايلك", "Please go to Car now": "يا ريت تروح لعند السيارة هلا", "Please select a reason first": "اختر السبب أول شي", "Please set a valid SOS phone number.": "يا ريت تحط رقم طوارئ صح.", "Please slow down": "يا ريت تخفف سرعة", "Please wait while we prepare your trip.": "انتظر شوي عم نجهز المشوار.", "Preferences": "التفضيلات", "Profile photo updated": "تم تحديث صورة الغلاف", "Quick Message": "رسالة سريعة", "Rating is": "التقييم هو", "Received empty route data.": "تم استلام بيانات طريق فارغة.", "Record": "تسجيل", "Record your trips to see them here.": "سجل مشاويرك لتشوفهم هون.", "Rejected Orders Count": "عدد الطلبات المرفوضة", "Remove waypoint": "حذف نقطة التوقف", "Report": "الإبلاغ", "Route and prices have been calculated successfully!": "تم حساب الطريق والأسعار بنجاح!", "SOS": "نجدة SOS", "Save": "حفظ", "Save Changes": "حفظ التغييرات", "Save Name": "حفظ الاسم", "Search country": "البحث عن الدولة", "Search for a starting point": "ابحث عن نقطة انطلاق", "Select Appearance": "اختر المظهر", "Select Education": "اختر مستوى التعليم", "Select Gender": "اختر الجنس", "Select This Ride": "اختر هالمشوار", "Select betweeen types": "اختر بين الأنواع", "Send Email": "إرسال إيميل", "Send SOS": "إرسال نجدة", "Send WhatsApp Message": "إرسال رسالة واتساب", "Server Error": "خطأ بالسيرفر", "Server error": "خطأ بالسيرفر", "Server error. Please try again.": "خطأ بالسيرفر. جرب مرة تانية.", "Set Destination": "تحديد الوجهة", "Set Phone Number": "تعيين رقم الموبايل", "Set as Home": "تحديد كالبيت", "Set as Stop": "تحديد كنقطة توقف", "Set as Work": "تحديد كالشغل", "Share": "مشاركة", "Share Trip": "مشاركة المشوار", "Share your experience to help us improve...": "شاركنا تجربتك لنحسن خدمتنا...", "Something went wrong. Please try again.": "صار غلط. جرب مرة تانية.", "Speaking...": "عم يحكي...", "Speed Over": "تجاوز السرعة", "Start Point": "نقطة البداية", "Stay calm. We are here to help.": "خليك هادي. نحن هون لمساعدتك.", "Stop": "توقف", "Submit Rating": "إرسال التقييم", "Support & Info": "الدعم والمعلومات", "System Default": "حسب النظام", "Take a Photo": "التقاط صورة", "Tap to apply your discount": "اضغط لتطبيق الخصم", "Tap to search your destination": "اضغط للبحث عن وجهتك", "The driver cancelled the trip.": "الكابتن كنسل المشوار.", "This action cannot be undone.": "هالإجراء ما بيتراجع عنه.", "This action is permanent and cannot be undone.": "هالإجراء دائم وما بيتراجع عنه.", "This is for delivery or a motorcycle.": "هاد للتوصيل أو الدراجة النارية.", "Time": "الوقت", "To :": "إلى :", "Top up Balance": "شحن الرصيد", "Top up Balance to continue": "اشحن رصيدك لتكمل", "Total Invites": "مجموع الدعوات", "Total Price": "السعر الإجمالي", "Trip booked successfully": "تم حجز المشوار بنجاح", "Type your message...": "اكتب رسالتك...", "Unknown Location": "موقع غير معروف", "Update Name": "تحديث الاسم", "Verified Passenger": "راكب موثق", "View Map": "عرض الخريطة", "Wait for the trip to start first": "استنى ليبلش المشوار أول", "Waiting...": "بانتظار...", "Warning": "تحذير", "Waypoint has been set successfully": "تم تعيين نقطة التوقف بنجاح", "We use location to get accurate and nearest driver for you": "منستخدم لوكيشنك لنلاقي أقرب كابتن إلك بدقة", "WhatsApp": "واتساب", "Why do you want to cancel?": "ليش بدك تكنسل؟", "Yes": "إي", "You should ideintify your gender for this type of trip!": "لازم تحدد جنسك لهالنوع من المشاوير!", "You will choose one of above!": "لازم تختار واحد من فوق!", "Your Rewards": "مكافآتك", "Your complaint has been submitted.": "تم إرسال شكوتك.", "and acknowledge our Privacy Policy.": "وأقر بسياسة الخصوصية الخاصة بنا.", "as the driver.": "ككابتن.", "cancelled": "تكنسل", "due to a previous trip.": "عن مشوار قديم.", "insert sos phone": "دخل رقم طوارئ", "is driving a": "عم يسوق", "min added to fare": "دقيقة نضافت للأجرة", "phone not verified": "رقم الموبايل مو متأكد", "to arrive you.": "ليوصلك.", "unknown": "غير معروف", "wait 1 minute to recive message": "استنى دقيقة لتستلم الرسالة", "with license plate": "برقم اللوحة", "witout zero": "بدون صفر", "you must insert token code": "لازم تدخل الكود", } def inject(): # 1. Read the missing keys from JSON file outputted earlier # We will just inject ALL these ARABIC_TRANS keys into the codebase if missing file_path = 'lib/controller/local/translations.dart' with open(file_path, 'r', encoding='utf-8') as f: content = f.read() # Find locales using regex e.g. "ar": { or "ar_SA": { or "en": { # It finds the locale name pattern = re.compile(r'(\n\s*)"([a-zA-Z_]+)":\s*\{') new_content = "" last_idx = 0 for match in pattern.finditer(content): # We append what we had before new_content += content[last_idx:match.end()] last_idx = match.end() locale = match.group(2) is_arabic = locale.startswith('ar') # Determine the insertion string for this locale addons = [] for key, ar_val in ARABIC_TRANS.items(): # If the exact key doesn't exist in the file (naively checking inside the whole file, # or we can just inject avoiding duplicates if it is not in the remaining text section) # A safer check: if f'"{key}"' not in content and f"'{key}'" not in content: addon = "" if is_arabic: addon = f'\n "{key}": "{ar_val}",' else: addon = f'\n "{key}": "{key}",' addons.append(addon) new_content += "".join(addons) new_content += content[last_idx:] with open(file_path, 'w', encoding='utf-8') as f: f.write(new_content) print(f"Successfully injected {len(ARABIC_TRANS)} missing keys into all locales.") if __name__ == "__main__": inject()