from pathlib import Path
root=Path('/home/ubuntu/clinic-management')
views=root/'resources/views'
for filename,mapping in {
'admin_revenue_report.blade.php':{
"@extends('layout',['heading'=>'تقرير الإيرادات الشهرية'])":"@extends('layout',['heading'=>__('ui.monthly_revenue_report')])",
'تقرير الإيرادات الشهرية':"{{ __('ui.monthly_revenue_report') }}",
'حركة اشتراكات جميع العيادات مع فصل الكاش عن إنستاباي':"{{ __('ui.revenue_report_intro') }}",
'العودة إلى لوحة النظام':"{{ __('ui.back_to_system_dashboard') }}",
'من تاريخ':"{{ __('ui.from_date') }}",
'إلى تاريخ':"{{ __('ui.to_date') }}",
'تصفية التقرير':"{{ __('ui.filter_report') }}",
'إلغاء التصفية':"{{ __('ui.clear_filter') }}",
'إجمالي الكاش':"{{ __('ui.total_cash') }}",
'إجمالي إنستاباي':"{{ __('ui.total_instapay') }}",
'الإجمالي العام':"{{ __('ui.grand_total') }}",
'الحركة الشهرية':"{{ __('ui.monthly_activity') }}",
'الشهر':"{{ __('ui.month') }}",
'عدد العمليات':"{{ __('ui.transaction_count') }}",
'لا توجد إيرادات ضمن الفترة المحددة':"{{ __('ui.no_revenue_period') }}",
'الإيرادات حسب العيادة':"{{ __('ui.revenue_by_clinic') }}",
'الكود':"{{ __('ui.code') }}",
'لا توجد بيانات':"{{ __('ui.no_data') }}",
'جنيه':"{{ __('ui.currency') }}",
},
'admin_feature_flags.blade.php':{
'تفعيل الهياكل الجديدة تدريجياً لكل عيادة.':"{{ __('ui.feature_flags_intro') }}",
'العودة للوحة النظام':"{{ __('ui.back_to_system_dashboard') }}",
'إضافة أو تحديث ميزة':"{{ __('ui.add_update_feature') }}",
'اختر العيادة':"{{ __('ui.choose_clinic') }}",
'مفعلة':"{{ __('ui.enabled') }}",
'معطلة':"{{ __('ui.disabled') }}",
'حفظ':"{{ __('ui.save') }}",
'الميزات الحالية':"{{ __('ui.current_features') }}",
'الميزة':"{{ __('ui.feature') }}",
'النسبة':"{{ __('ui.percentage') }}",
'آخر تعديل':"{{ __('ui.last_updated') }}",
'لا توجد Feature Flags مخصصة.':"{{ __('ui.no_feature_flags') }}",
},
}.items():
    p=views/filename
    s=p.read_text()
    for old,new in mapping.items(): s=s.replace(old,new)
    p.write_text(s)

keys_en={
'monthly_revenue_report':'Monthly revenue report','revenue_report_intro':'Subscription activity for all clinics, separated into cash and InstaPay.','filter_report':'Filter report','total_cash':'Total cash','total_instapay':'Total InstaPay','grand_total':'Grand total','monthly_activity':'Monthly activity','month':'Month','transaction_count':'Transactions','no_revenue_period':'No revenue for the selected period.','revenue_by_clinic':'Revenue by clinic','code':'Code','no_data':'No data','feature_flags_intro':'Gradually enable new structures for each clinic.','add_update_feature':'Add or update feature','enabled':'Enabled','disabled':'Disabled','current_features':'Current features','feature':'Feature','percentage':'Percentage','last_updated':'Last updated','no_feature_flags':'No custom Feature Flags.'}
keys_ar={'monthly_revenue_report':'تقرير الإيرادات الشهرية','revenue_report_intro':'حركة اشتراكات جميع العيادات مع فصل الكاش عن إنستاباي','filter_report':'تصفية التقرير','total_cash':'إجمالي الكاش','total_instapay':'إجمالي إنستاباي','grand_total':'الإجمالي العام','monthly_activity':'الحركة الشهرية','month':'الشهر','transaction_count':'عدد العمليات','no_revenue_period':'لا توجد إيرادات ضمن الفترة المحددة','revenue_by_clinic':'الإيرادات حسب العيادة','code':'الكود','no_data':'لا توجد بيانات','feature_flags_intro':'تفعيل الهياكل الجديدة تدريجياً لكل عيادة.','add_update_feature':'إضافة أو تحديث ميزة','enabled':'مفعلة','disabled':'معطلة','current_features':'الميزات الحالية','feature':'الميزة','percentage':'النسبة','last_updated':'آخر تعديل','no_feature_flags':'لا توجد Feature Flags مخصصة.'}
for locale,keys in [('en',keys_en),('ar',keys_ar)]:
    p=root/f'lang/{locale}/ui.php'; s=p.read_text(); marker='\n];'
    additions=''.join(f"    '{k}' => {v!r},\n" for k,v in keys.items())
    s=s.replace(marker,'\n'+additions+'];',1); p.write_text(s)
print('remaining admin pages translated')
