import sys import re def fix_translations(filepath): with open(filepath, 'r') as f: content = f.read() # Pattern to match "SYP": "..." and inject "EGP" and "JOD" right after it. def replace_syp(match): syp_line = match.group(0) # e.g. "SYP": "ل.س", syp_val = match.group(1) # e.g. ل.س # Decide what EGP and JOD should be based on the SYP translation if 'ل.س' in syp_val: egp_val = syp_val.replace('ل.س', 'ج.م') jod_val = syp_val.replace('ل.س', 'د.أ') elif 'SYP' in syp_val: egp_val = syp_val.replace('SYP', 'EGP') jod_val = syp_val.replace('SYP', 'JOD') else: # Fallback egp_val = 'EGP' jod_val = 'JOD' egp_line = syp_line.replace('SYP', 'EGP').replace(syp_val, egp_val) jod_line = syp_line.replace('SYP', 'JOD').replace(syp_val, jod_val) return f'{syp_line}\n {egp_line}\n {jod_line}' # "SYP": "ل.س", content = re.sub(r'"SYP"\s*:\s*"([^"]+)",', replace_syp, content) # "You have gift 300 SYP": "عندك هدية 300 ل.س", content = re.sub(r'"You have gift 300 SYP"\s*:\s*"([^"]+)",', replace_syp, content) # "You have gift 30000 SYP": "عندك هدية 30000 ل.س", content = re.sub(r'"You have gift 30000 SYP"\s*:\s*"([^"]+)",', replace_syp, content) with open(filepath, 'w') as f: f.write(content) print(f"Fixed {filepath}") def fix_json(filepath): with open(filepath, 'r') as f: content = f.read() def replace_syp_json(match): syp_line = match.group(0) egp_line = syp_line.replace('SYP', 'EGP') jod_line = syp_line.replace('SYP', 'JOD') return f'{syp_line}\n {egp_line}\n {jod_line}' content = re.sub(r'"Points"\s*:\s*"SYP",', replace_syp_json, content) with open(filepath, 'w') as f: f.write(content) print(f"Fixed {filepath}") if __name__ == '__main__': fix_translations('siro_rider/lib/controller/local/translations.dart') fix_translations('siro_driver/lib/controller/local/translations.dart') fix_json('siro_driver/lib/translations_en.json')