#!/usr/bin/env python3
"""Check which document-translation controls exist for one language pair.

Usage: python3 pair_check.py SOURCE TARGET   (DeepL codes, e.g. EN DE, JA EN-US)

Reads deepl-languages-2026-11-25.csv from the same folder. That file was copied
from DeepL's public supported-languages page on 2026-11-25 (glossary and
target-only flags) and DeepL's formality help article (formality). DeepL does
not publish per-language document support, so this script does not claim it:
confirm with GET /v3/languages?resource=translate_document if you have an API key.
Google Translate's Documents tab has no glossary or formality setting at all.
"""
import csv, os, sys

HERE = os.path.dirname(os.path.abspath(__file__))
rows = {r["code"]: r for r in csv.DictReader(open(os.path.join(HERE, "deepl-languages-2026-11-25.csv"), encoding="utf-8"))}

def main():
    if len(sys.argv) != 3:
        sys.exit(__doc__)
    s, t = sys.argv[1].upper(), sys.argv[2].upper()
    for code, role in ((s, "source"), (t, "target")):
        if code not in rows:
            print(f"{code}: not found in DeepL's list as of 2026-11-25. Check the code; if it is right, DeepL does not offer this {role} language and Google is the option to try.")
            return
    src, tgt = rows[s], rows[t]
    if src["target_only"] == "yes":
        print(f"{s} is a target-only variant. Use {s.split('-')[0]} as the source code.")
        return
    gloss = src["glossary"] == "yes" and tgt["glossary"] == "yes"
    form = tgt["formality"]
    print(f"Pair {s} -> {t} ({src['name']} -> {tgt['name']})")
    print(f"  DeepL glossary on this pair: {'yes' if gloss else 'no'} (both languages must support glossaries)")
    print(f"  DeepL formality for target:  {'yes' if form == 'yes' else ('polite/plain tone only' if form == 'polite/plain' else 'no')}")
    print("  DeepL plan limits: glossary 5 entries per pair on Free and Pro Individual, 1,000 on Team;")
    print("                     tone setting on paid plans only")
    print("  Google Translate Documents tab: no glossary, no formality setting")
    print("  Google Cloud Translation (Advanced): glossary supported on documents; check the target in its language list")
    if not gloss:
        print("  -> No enforced terminology on either consumer tool. Plan a terminology review pass.")

if __name__ == "__main__":
    main()
