#!/usr/bin/env python3 """ Script to apply all batch translations to the main django.po file """ import re def apply_all_translations(): """ Apply all translations to the main django.po file """ # All translations from batches 02-35 translations = { "The date and time this notification is scheduled to be sent.": "التاريخ والوقت المحدد لإرسال هذا الإشعار.", "Send Attempts": "محاولات الإرسال", "Failed to start the job posting process. Please try again.": "فشل في بدء عملية نشر الوظيفة. يرجى المحاولة مرة أخرى.", "You don't have permission to view this page.": "ليس لديك إذن لعرض هذه الصفحة.", "Account Inactive": "الحساب غير نشط", "Princess Nourah bint Abdulrahman University": "جامعة الأميرة نورة بنت عبدالرحمن", "Manage your personal details and security.": "إدارة تفاصيلك الشخصية والأمان.", "Primary": "أساسي", "Verified": "موثق", "Unverified": "غير موثق", "Make Primary": "جعل أساسي", "Remove": "إزالة", "Add Email Address": "إضافة عنوان بريد إلكتروني", "Hello,": "مرحباً،", "Confirm My KAAUH ATS Email": "تأكيد بريدي الإلكتروني في نظام توظيف جامعة نورة", "Alternatively, copy and paste this link into your browser:": "بدلاً من ذلك، انسخ والصق هذا الرابط في متصفحك:", "Password Reset Request": "طلب إعادة تعيين كلمة المرور", "Click Here to Reset Your Password": "اضغط هنا لإعادة تعيين كلمة المرور", "This link is only valid for a limited time.": "هذا الرابط صالح لفترة محدودة فقط.", "Thank you,": "شكراً لك،", "KAAUH ATS Team": "فريق نظام توظيف جامعة نورة", "Confirm Email Address": "تأكيد عنوان البريد الإلكتروني", "Account Verification": "التحقق من الحساب", "Verify your email to secure your account and unlock full features.": "تحقق من بريدك الإلكتروني لتأمين حسابك وإلغاء قفل جميع الميزات.", "Confirm Your Email Address": "تأكيد عنوان بريدك الإلكتروني", "Verification Failed": "فشل التحقق", "The email confirmation link is expired or invalid.": "رابط تأكيد البريد الإلكتروني منتهي الصلاحية أو غير صالح.", "Keep me signed in": "ابق مسجلاً للدخول", "Return to Profile": "العودة إلى الملف الشخصي", "Enter your e-mail address to reset your password.": "أدخل عنوان بريدك الإلكتروني لإعادة تعيين كلمة المرور.", "Remember your password?": "تتذكر كلمة المرور؟", "Log In": "تسجيل الدخول", "Password Reset Sent": "تم إرسال إعادة تعيين كلمة المرور", "Return to Login": "العودة إلى تسجيل الدخول", "Please enter your new password below.": "يرجى إدخال كلمة المرور الجديدة أدناه.", "Logout": "تسجيل الخروج", "Yes": "نعم", "No": "لا", "Success": "نجح", "Login": "تسجيل الدخول", "Link": "ربط", "Clear": "مسح", "All": "الكل", "Comments": "التعليقات", "Save": "حفظ", "Notes": "ملاحظات", "New": "جديد", "Users": "المستخدمون", "Filter": "تصفية", "Home": "الرئيسية", "Username": "اسم المستخدم", "Modified": "تم التعديل", "Unlink": "فك الربط", "Group": "تجميع", "Export": "تصدير", "Import": "استيراد", "None": "لا شيء", "Add": "إضافة", "True": "صحيح", "False": "خطأ", } main_po_file = "locale/ar/LC_MESSAGES/django.po" # Read the main django.po file with open(main_po_file, 'r', encoding='utf-8') as f: main_content = f.read() # Apply translations to main file updated_content = main_content applied_count = 0 for english, arabic in translations.items(): # Pattern to find msgid followed by empty msgstr pattern = rf'(msgid "{re.escape(english)}"\s*\nmsgstr) ""' replacement = rf'\1 "{arabic}"' if re.search(pattern, updated_content): updated_content = re.sub(pattern, replacement, updated_content) applied_count += 1 print(f"✓ Applied: '{english}' -> '{arabic}'") else: print(f"✗ Not found: '{english}'") # Write updated content back to main file with open(main_po_file, 'w', encoding='utf-8') as f: f.write(updated_content) print(f"\nApplied {applied_count} translations to {main_po_file}") return applied_count def main(): """Main function to apply all translations""" print("Applying all batch translations to main django.po file...") applied_count = apply_all_translations() if applied_count > 0: print(f"\n✅ Successfully applied {applied_count} translations!") print("Next steps:") print("1. Run: python manage.py compilemessages") print("2. Test the translations in the application") else: print("\n❌ No translations were applied.") if __name__ == "__main__": main()