Files
dragon-hd/tools/check_translations.py
DragonHD ca5748821c Translate Strings.dat to Simplified Chinese (479/496)
- cn_strings.py: full GB2312 translation table; make_cn_strings.py is now
  escape-aware so values containing escaped-quote formats survive.
- dump_all_strings.py + check_translations.py: dump the English table and
  verify the printf specifier sequence matches the source (0 mismatches).
- Skipped: pure-format/empty strings, the tutorial texture path, ambiguous
  key labels.
- DEVLOG notes the remaining engine-layout caveats.
2026-09-20 10:44:10 +08:00

34 lines
986 B
Python

import json
import re
import sys
sys.path.insert(0, r"E:\DragonHD\tools")
from cn_strings import CN_STRINGS
j = json.load(open(r"E:\DragonHD\build\strings_en.json", encoding="utf-8"))
en = {k: v for k, v in j}
SPEC = re.compile(r"%%|%[-+ #0]*[\d*]*(?:\.[\d*]+)?[hlL]?[diouxXeEfgGcs%]")
bad = []
for sid, cn in CN_STRINGS.items():
if sid not in en:
bad.append((sid, "id not in file"))
continue
se = SPEC.findall(en[sid])
sc = SPEC.findall(cn)
if se != sc:
bad.append((sid, "spec %r != %r" % (se, sc)))
print("translated:", len(CN_STRINGS))
print("spec mismatches:", len(bad))
for sid, why in bad:
print(" !", sid, why)
# specifiers present in English but missing translation
missing_spec = [sid for sid in en if sid not in CN_STRINGS and SPEC.findall(en[sid]) and en[sid].strip()]
print()
print("English entries with format specifiers left untranslated:", len(missing_spec))
for s in missing_spec:
print(" -", s, "=", repr(en[s]))