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')
+6
View File
@@ -26,6 +26,12 @@ import Foundation
let locale = Locale(identifier: language)
precondition(AppLocalization.string("settings.title", locale: locale, bundle: bundle) == title)
precondition(AppLocalization.string("accent.custom", locale: locale, bundle: bundle) == custom)
for (table, key) in [("StatusItem", "status.open"), ("Process", "copyPID"), ("CPUDetails", "cpu.kind.efficiency")] {
let value = AppLocalization.string(key, locale: locale, bundle: bundle, table: table)
precondition(!value.isEmpty && value != key, "Missing built translation: \(language)/\(table)/\(key)")
}
let average = AppLocalization.string("gpu.recentAverage", locale: locale, bundle: bundle)
precondition(average == ["en": "Last-minute average", "zh-Hans": "近 1 分钟平均", "zh-Hant": "近 1 分鐘平均"][language])
}
print("PASS: system matching, explicit override, fallback, preference roundtrip, built three-language resources")
}
+2
View File
@@ -216,3 +216,5 @@ swiftc -parse-as-library kymo/Core/Models/*.swift kymo/Core/Monitors/*.swift kym
swiftc -parse-as-library kymo/Core/Services/PublicIPAddressService.swift kymoTests/PublicIPAddressChecks.swift -o /private/tmp/kymo-ip-checks
/private/tmp/kymo-ip-checks
```
完整字符串表覆盖与格式参数检查:`python3 kymoTests/LocalizationCatalogChecks.py`。以 zh-Hans 为参数语义基准检查三语完整性,不能替代翻译语义审阅和界面排版验收。