from pathlib import Path
p=Path('/home/ubuntu/clinic-management/resources/views/admin_clinics.blade.php')
s=p.read_text()
# Remaining table labels and JS fragments.
for old,new in {
    '>الكود</th>': ">{{ __('ui.code') }}</th>",
    '>العيادة</th>': ">{{ __('ui.clinic') }}</th>",
    '>النوع</th>': ">{{ __('ui.type') }}</th>",
    '>بداية الاشتراك</th>': ">{{ __('ui.subscription_start') }}</th>",
    '>نهاية الاشتراك</th>': ">{{ __('ui.subscription_end') }}</th>",
    '>المبلغ</th>': ">{{ __('ui.amount') }}</th>",
    '>طريقة الدفع</th>': ">{{ __('ui.payment_method') }}</th>",
    '>إجراء</th>': ">{{ __('ui.action') }}</th>",
    'دخول: ': "{{ __('ui.login_label') }}: ",
    ' جنيه</td>': " {{ __('ui.currency') }}</td>",
    "?'إنستاباي':'كاش'": "?__('ui.instapay') : __('ui.cash')",
    "'إنستاباي':'كاش'": "__('ui.instapay') : __('ui.cash')",
    "+' '+{{ __('ui.currency') }}}": "+' '+{{ __('ui.currency')|json_encode }} }",
    "<label>عدد {{ __('ui.doctors') }} في الفرع '+i": "<label>{{ __('ui.doctors_in_branch') }} '+i",
    'placeholder="الأطباء"': "placeholder=\"{{ __('ui.doctors') }}\"",
    'placeholder="اشتراطات {{ $sp }}"': "placeholder=\"{{ __('ui.requirements') }} {{ $sp }}\"",
}.items():
    s=s.replace(old,new)
p.write_text(s)

# Replace remaining source fragments in the other templates.
for filename,mapping in {
'admin_clinics_report.blade.php': {
    "['normal'=>'عادية','multi_branch'=>'متعددة الفروع','multi_specialty'=>'متعددة التخصصات','multi_branch_specialty'=>'متعددة الفروع والتخصصات']": "['normal'=>__('ui.normal_clinic'),'multi_branch'=>__('ui.multi_branch'),'multi_specialty'=>__('ui.multi_specialty'),'multi_branch_specialty'=>__('ui.multi_branch_specialty')]",
    "['monthly'=>'شهري','quarterly'=>'ربع سنوي','semiannual'=>'نصف سنوي','annual'=>'سنوي']": "['monthly'=>__('ui.monthly'),'quarterly'=>__('ui.quarterly'),'semiannual'=>__('ui.semiannual'),'annual'=>__('ui.annual')]",
    ' ج.م': " {{ __('ui.currency') }}",
    'التخصصات': "{{ __('ui.specialties') }}",
},
'admin_subscription_pricing.blade.php': {
    'إضافة الأطباء': "{{ __('ui.add_doctors') }}",
    'قبل إضافة الفروع والأطباء': "{{ __('ui.before_adding_branches_doctors') }}",
    'عدد الفروع': "{{ __('ui.branch_count') }}",
    'عدد الأطباء': "{{ __('ui.doctors') }}",
    'السعر الأساسي': "{{ __('ui.base_price') }}",
    'سعر الفرع': "{{ __('ui.branch_price') }}",
    'سعر الطبيب': "{{ __('ui.doctor_price') }}",
},
'admin_feature_flags.blade.php': {
    "$flag->enabled ? 'مفعلة' : 'معطلة'": "$flag->enabled ? __('ui.enabled') : __('ui.disabled')",
    'الحالة</th>': "{{ __('ui.status') }}</th>",
    'العيادة</th>': "{{ __('ui.clinic') }}</th>",
},
'reset_clinic_password.blade.php': {
    ' حفظ كلمة المرور الجديدة': ' {{ __(\'ui.save_new_password\') }}',
    ' تأكيد كلمة المرور الجديدة': ' {{ __(\'ui.confirm_new_password\') }}',
}
}.items():
    p=Path('/home/ubuntu/clinic-management/resources/views')/filename
    s=p.read_text()
    for old,new in mapping.items(): s=s.replace(old,new)
    p.write_text(s)
print('fixed i18n leftovers')
