GrepBoard/Manuals
605 manuals ·

Check AI translation term consistency against a glossary CSV

·Tested on Claude Sonnet 5.5 · Claude Code 2.1.302 · Python 3 · Ubuntu 24.04 · 2026-10·Test scope ↓·8 steps

Compare a glossary CSV with an AI translation in Python to flag forbidden terms, missing terms and source words left untranslated, with real runs and counts.

After translating into Korean, check by script whether "workspace" came out as 워크스페이스 in one paragraph and 작업 공간 in another. The same match-against-the-source idea is used in Get Claude's proofreading as a changes-only table.

[1] Write the glossary as a CSV: source term, required translation, forbidden translations (separated by ;).

glossary.csv
source,target,forbiddenworkspace,워크스페이스,작업공간;작업 공간;작업 영역dashboard,대시보드,계기판;현황판deploy,배포,디플로이;전개rollback,롤백,되돌리기;원상 복구;원상복구access token,액세스 토큰,접근 토큰;접속 토큰;억세스 토큰webhook,웹훅,웹 훅;웹후크audit log,감사 로그,감사 기록;감사로그

[2] Put the English source in source.en.txt. The test text is a five-paragraph product notice that repeats the glossary words (workspace 5 times, dashboard 4, deploy 5, and so on).

[3] Write the checker. It counts each term in the source, then looks for three things in the translation: MISSING (the required translation never appears), FORBIDDEN (a banned rendering appears) and UNTRANSLATED (the source word was left as is). Any hit makes the exit code 1.

check.py
#!/usr/bin/env python3"""usage: check.py glossary.csv source.txt translation.txt"""import csv, re, sysgloss = list(csv.DictReader(open(sys.argv[1], encoding="utf-8")))src = open(sys.argv[2], encoding="utf-8").read().lower()dst = " ".join(open(sys.argv[3], encoding="utf-8").read().split())bad = 0for g in gloss:    s = g["source"]    n_src = len(re.findall(r"\b" + re.escape(s) + r"s?\b", src))    if n_src == 0:        continue    n_ok = dst.count(g["target"])    banned = {f: dst.count(f) for f in g["forbidden"].split(";") if f and dst.count(f)}    status = []    left = len(re.findall(re.escape(s), dst, flags=re.I))    if left:        status.append(f"UNTRANSLATED {s!r} x{left}"); bad += left    if n_ok == 0:        status.append("MISSING"); bad += 1    for f, c in banned.items():        status.append(f"FORBIDDEN {f!r} x{c}"); bad += c    print(f"{s:13} src {n_src}x  target {g['target']!r} {n_ok}x  " + ("; ".join(status) or "ok"))print(f"violations: {bad}")sys.exit(1 if bad else 0)

[4] Translate without a glossary. Tools are off and the model answers in one turn.

console
$ claude -p --model claude-sonnet-5-5 --max-turns 1 --tools "" < prompt.txt > out.plain.1.txt

prompt.txt is one line, Translate the text inside <text> into Korean. Output only the translation., followed by the source wrapped in <text>.

[5] Check it.

console
$ python3 -I check.py glossary.csv source.en.txt out.plain.1.txtworkspace     src 5x  target '워크스페이스' 5x  okdashboard     src 4x  target '대시보드' 4x  okdeploy        src 5x  target '배포' 6x  okrollback      src 3x  target '롤백' 3x  UNTRANSLATED 'rollback' x1access token  src 2x  target '액세스 토큰' 2x  okwebhook       src 1x  target '웹훅' 1x  okaudit log     src 1x  target '감사 로그' 1x  okviolations: 1

All seven terms used the required translation. The one hit is the button name Rollback, left in English. A second run (out.plain.2.txt) had the same single hit. The checker does not flag deploy being translated 6 times for 5 source uses.

[6] Repeat with the glossary in the prompt. Each glossary line looks like - workspace -> 워크스페이스, preceded by a sentence saying to use exactly these terms and no other rendering.

console
$ claude -p --model claude-sonnet-5-5 --max-turns 1 --tools "" < prompt-g.txt > out.gloss.1.txt$ python3 -I check.py glossary.csv source.en.txt out.gloss.1.txt | tail -1violations: 0

Both runs together:

RunGlossaryViolations
plain 1no1 (Rollback untranslated)
plain 2no1 (Rollback untranslated)
gloss 1yes0
gloss 2yes1 (Rollback untranslated)

Four runs are too few to say the glossary reduces violations. Here the glossary terms match what the model picks anyway (워크스페이스, 대시보드, 배포), so there was nothing to fix.

[7] See what the checker reports when the glossary disagrees with the model's default. Suppose house style is:

glossary-b.csv
source,target,forbiddenworkspace,작업 공간,워크스페이스dashboard,현황판,대시보드deploy,디플로이,배포rollback,롤백,되돌리기access token,액세스 토큰,접근 토큰;접속 토큰webhook,웹훅,웹 훅audit log,감사 로그,감사 기록

Check the no-glossary translation out.plain.1.txt against it.

console
$ python3 -I check.py glossary-b.csv source.en.txt out.plain.1.txt; echo "exit $?"workspace     src 5x  target '작업 공간' 0x  MISSING; FORBIDDEN '워크스페이스' x5dashboard     src 4x  target '현황판' 0x  MISSING; FORBIDDEN '대시보드' x4deploy        src 5x  target '디플로이' 0x  MISSING; FORBIDDEN '배포' x6rollback      src 3x  target '롤백' 3x  UNTRANSLATED 'rollback' x1access token  src 2x  target '액세스 토큰' 2x  okwebhook       src 1x  target '웹훅' 1x  okaudit log     src 1x  target '감사 로그' 1x  okviolations: 19exit 1

A translation made without the glossary drifts from house style, and the script puts a number on it. Whether the model follows glossary B when it is put in the prompt was not tested; the call budget was spent.

[8] Fix the flagged lines by hand. The checker only sees whether a term appears. It cannot judge fit or fluency, and it misses source words that appear in another form such as a verb (roll back).

#claude#translation#glossary#python