fix(l10n): 以简体中文统一英文与繁体翻译并校验完整性

This commit is contained in:
2026-11-03 20:39:06 +08:00
parent 1f02810b9a
commit 3b1e711556
11 changed files with 688 additions and 503 deletions
+25
View File
@@ -0,0 +1,25 @@
"""Validate catalog coverage and printf argument compatibility against zh-Hans."""
import collections
import json
from pathlib import Path
import re
root = Path(__file__).resolve().parents[1] / 'kymo/Resources'
pattern = re.compile(r'%(?:(\d+)\$)?[-+#0 ]*(?:\d+)?(?:\.\d+)?(ll|l|h)?([@diuoxXfFeEgGcCsSp])')
def arguments(text):
result = collections.Counter()
for index, match in enumerate(pattern.finditer(text.replace('%%', '')), 1):
result[(int(match[1] or index), (match[2] or '') + match[3])] += 1
return result
count = 0
for path in sorted(root.glob('*.xcstrings')):
for key, entry in json.loads(path.read_text())['strings'].items():
units = {locale: entry['localizations'][locale]['stringUnit']
for locale in ['zh-Hans', 'en', 'zh-Hant']}
for locale, unit in units.items():
assert unit['state'] == 'translated' and unit['value'].strip(), (path, key, locale)
assert arguments(unit['value']) == arguments(units['zh-Hans']['value']), (path, key, locale)
count += 1
print(f'PASS: {count} catalog entries, three-language coverage and format arguments')