"""Apply reviewed mechanical repairs where NLLB corrupted protected placeholders."""

import json
from pathlib import Path

PATH = Path(__file__).resolve().parents[1] / "content" / "speech" / "tracking" / "machine-translation-memory.json"
memory = json.loads(PATH.read_text(encoding="utf-8"))
repairs = {
    "mr": {
        "Choose the green one or the {alternative_attribute} one.": "हिरवी वस्तू किंवा {alternative_attribute} वस्तू निवडा.",
        "Do you want father or {alternative_choice}?": "तुला बाबा किंवा {alternative_choice} हवे आहेत का?",
        "Do you want the apple or the {alternative_object}?": "तुला सफरचंद किंवा {alternative_object} हवे आहे का?",
        "Do you want the big one or the {alternative_attribute} one?": "तुला मोठी वस्तू किंवा {alternative_attribute} वस्तू हवी आहे का?",
        "Do you want the blue one or the {alternative_attribute} one?": "तुला निळी वस्तू किंवा {alternative_attribute} वस्तू हवी आहे का?",
        "Do you want the cup or the {alternative_object}?": "तुला कप किंवा {alternative_object} हवा आहे का?",
        "Do you want the eye or the {alternative_object}?": "तुला डोळा किंवा {alternative_object} हवा आहे का?",
        "Do you want the foot or the {alternative_object}?": "तुला पाय किंवा {alternative_object} हवा आहे का?",
        "Do you want the green one or the {alternative_attribute} one?": "तुला हिरवी वस्तू किंवा {alternative_attribute} वस्तू हवी आहे का?",
        "Do you want the orange or the {alternative_object}?": "तुला संत्रे किंवा {alternative_object} हवे आहे का?",
        "Do you want the red one or the {alternative_attribute} one?": "तुला लाल वस्तू किंवा {alternative_attribute} वस्तू हवी आहे का?",
        "Do you want the shirt or the {alternative_object}?": "तुला शर्ट किंवा {alternative_object} हवा आहे का?",
        "Do you want the spoon or the {alternative_object}?": "तुला चमचा किंवा {alternative_object} हवा आहे का?",
    },
    "bn": {
        "Do you want on or {alternative_choice}?": "তুমি কি ‘উপরে’ নাকি {alternative_choice} চাও?",
    },
}
for language, values in repairs.items():
    memory["translations"][language].update(values)
PATH.write_text(json.dumps(memory, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
print(f"Repaired {sum(map(len, repairs.values()))} placeholder translations")
