fix(ui): 校正三语指标文案并核对构建包译文

This commit is contained in:
2026-11-16 00:17:42 +08:00
parent 3ee6b45eb4
commit 36518d29db
10 changed files with 172 additions and 38 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ CPU / GPU / 电量的零值与 100% 分别映射到卡片底边和顶边,内
- GPU Renderer / Tiler 是活动阶段指标,可能重叠,不能相加成为总占用。GPU 核心数不代表逐核计数;目前没有独立逐核 GPU 占用。 - GPU Renderer / Tiler 是活动阶段指标,可能重叠,不能相加成为总占用。GPU 核心数不代表逐核计数;目前没有独立逐核 GPU 占用。
- 网络“全部”仅汇总 active 且名称以 `en` 开头的接口,避免物理链路与 `utun` 双计。接口选择仍可查看其他活动接口;这个规则不等于所有设备和隧道的通用流量归因。 - 网络“全部”仅汇总 active 且名称以 `en` 开头的接口,避免物理链路与 `utun` 双计。接口选择仍可查看其他活动接口;这个规则不等于所有设备和隧道的通用流量归因。
- 进程 CPU 以一个逻辑核满载为 100%,多线程可超过 100%,不能直接与整机 CPU 百分比比较。首次进程采样没有差分值;功率列使用独立 CPU 能量计数差分,不能将进程 CPU 百分比当成耗电。 - 进程 CPU 以一个逻辑核满载为 100%,多线程可超过 100%,不能直接与整机 CPU 百分比比较。首次进程采样没有差分值;功率列使用独立 CPU 能量计数差分,不能将进程 CPU 百分比当成耗电。
- 电池卡片仅在非外接电源时显示剩余时间;外接电源显示不适用,系统未给出有效估计时显示未知。 - 电池卡片在系统报告充电时显示距充满的估时,电池供电时显示剩余续航。外接供电且未充电时显示不适用,系统未提供有效估时则显示相应提示。
## 采样与缓存周期 ## 采样与缓存周期
+1 -1
View File
@@ -52,7 +52,7 @@ python3 tools/check.py --list
| ReleaseServiceChecks(--services) | 临时 hardened sandbox 主程序调用本轮实际嵌入服务,核对同 UID footprint / 能量与传感器,并输出本机 B0AP 带符号瓦数或不可用状态 | | ReleaseServiceChecks(--services) | 临时 hardened sandbox 主程序调用本轮实际嵌入服务,核对同 UID footprint / 能量与传感器,并输出本机 B0AP 带符号瓦数或不可用状态 |
| SandboxNetworkChecks(--network) | 使用实际主应用 entitlement 访问产品 HTTPS 端点,核对持久网络目录无新增或变更文件 | | SandboxNetworkChecks(--network) | 使用实际主应用 entitlement 访问产品 HTTPS 端点,核对持久网络目录无新增或变更文件 |
LocalizationCatalogChecks.py 检查全部保留键的三语完整性与格式参数,不替代翻译语义和实际排版。服务 / 网络不可达也会使对应检查失败。 LocalizationCatalogChecks.py 检查全部词条的三语完整性与格式参数。统一检查入口还逐项比对构建包内四份字符串表与源译文;翻译语义和实际排版需另行核对。服务 / 网络不可达也会使对应检查失败。
## 实际应用验收 ## 实际应用验收
@@ -48,7 +48,8 @@ extension MenuPanelView {
return ResourceCard( return ResourceCard(
title: "metric.gpu", symbol: "square.grid.2x2", color: Color("MetricGPU"), value: MetricFormat.percent(snapshot.gpuUsage), title: "metric.gpu", symbol: "square.grid.2x2", color: Color("MetricGPU"), value: MetricFormat.percent(snapshot.gpuUsage),
titleBadge: snapshot.gpu?.coreCount.map { titleBadge: snapshot.gpu?.coreCount.map {
String(format: AppLocalization.string("gpu.coreCountFormat", locale: locale), $0) $0 == 1 ? AppLocalization.string("gpu.oneCore", locale: locale)
: String(format: AppLocalization.string("gpu.coreCountFormat", locale: locale), $0)
}, },
status: snapshot.gpuTemperature.map { "\(Int($0.rounded()))°C" }, status: snapshot.gpuTemperature.map { "\(Int($0.rounded()))°C" },
chartPlacement: .background, chartPlacement: .background,
@@ -110,7 +111,7 @@ extension MenuPanelView {
second: samples.map(\.memoryApp), third: samples.map(\.memoryWired), fourth: samples.map(\.memoryCompressed), second: samples.map(\.memoryApp), third: samples.map(\.memoryWired), fourth: samples.map(\.memoryCompressed),
color: Color("MemoryApplication"), secondColor: Color("MemoryApplication"), color: Color("MemoryApplication"), secondColor: Color("MemoryApplication"),
thirdColor: Color("MemoryWired"), fourthColor: Color("MemoryCompressed"), fixedScale: Double(snapshot.memory?.total ?? 1), thirdColor: Color("MemoryWired"), fourthColor: Color("MemoryCompressed"), fixedScale: Double(snapshot.memory?.total ?? 1),
firstValueFormat: .memory, firstLabel: "gpu.totalUtilization", firstValueFormat: .memory, firstLabel: "memory.used",
secondLabel: "memory.app", thirdLabel: "memory.wired", fourthLabel: "memory.compressed", secondLabel: "memory.app", thirdLabel: "memory.wired", fourthLabel: "memory.compressed",
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals, stackOrder: [1, 2, 3]) expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals, stackOrder: [1, 2, 3])
} }
+2 -1
View File
@@ -162,7 +162,8 @@ struct MenuPanelView: View {
HStack { HStack {
HStack(spacing: 4) { HStack(spacing: 4) {
Text("panel.uptime") Text("panel.uptime")
MetricText(value: String(format: "%.1f h", snapshot.uptime / 3600)) let hours = (snapshot.uptime / 3600).formatted(.number.precision(.fractionLength(1)).grouping(.never).locale(locale))
Text("duration.hours \(hours)").monospacedDigit()
}.fixedSize() }.fixedSize()
Divider().frame(height: 14) Divider().frame(height: 14)
Text(verbatim: HardwareIdentity.displayName) Text(verbatim: HardwareIdentity.displayName)
@@ -105,10 +105,10 @@ struct PowerResourceCard: View {
InlineMetric("battery.cyclesShort", battery.cycles.map(String.init) ?? "--") InlineMetric("battery.cyclesShort", battery.cycles.map(String.init) ?? "--")
} }
HStack(spacing: 4) { HStack(spacing: 4) {
Text("battery.timeShort").foregroundStyle(.secondary) Text(battery.flow.charging == true ? "battery.timeToFull" : "battery.timeShort").foregroundStyle(.secondary)
if let minutes = battery.minutesRemaining { if let minutes = battery.minutesRemaining {
MetricText(value: "\(minutes) min") Text("duration.minutes \(minutes)").monospacedDigit()
} else if battery.flow.state == .external { } else if battery.flow.state == .external && battery.flow.charging != true {
Text("battery.notApplicableShort").help(Text("battery.timeNotApplicable")) Text("battery.notApplicableShort").help(Text("battery.timeNotApplicable"))
} else { } else {
Text("battery.timeUnknown") Text("battery.timeUnknown")
+10 -7
View File
@@ -7,7 +7,7 @@ struct StorageDetailsView: View {
var body: some View { var body: some View {
VStack(alignment: .leading, spacing: 3) { VStack(alignment: .leading, spacing: 3) {
field("memory.available", value: MetricFormat.bytes(disk?.available)) field("memory.available", value: Text(verbatim: MetricFormat.bytes(disk?.available)))
ViewThatFits(in: .horizontal) { ViewThatFits(in: .horizontal) {
HStack(spacing: 6) { read; write }.fixedSize(horizontal: true, vertical: true) HStack(spacing: 6) { read; write }.fixedSize(horizontal: true, vertical: true)
VStack(alignment: .leading, spacing: 3) { read; write } VStack(alignment: .leading, spacing: 3) { read; write }
@@ -24,15 +24,18 @@ struct StorageDetailsView: View {
.font(.system(size: 10)).lineLimit(1) .font(.system(size: 10)).lineLimit(1)
} }
private var read: some View { field("disk.read", value: MetricFormat.rate(io?.read)) } private var read: some View { field("disk.read", value: Text(verbatim: MetricFormat.rate(io?.read))) }
private var write: some View { field("disk.write", value: MetricFormat.rate(io?.written)) } private var write: some View { field("disk.write", value: Text(verbatim: MetricFormat.rate(io?.written))) }
private var life: some View { field("disk.lifeShort", value: MetricFormat.percent(health?.remainingLife)) } private var life: some View { field("disk.lifeShort", value: Text(verbatim: MetricFormat.percent(health?.remainingLife))) }
private var powerOn: some View { field("disk.powerOnShort", value: health?.powerOnHours.map { "\($0) h" } ?? "--") } private var powerOn: some View {
let hours = health?.powerOnHours.map { Text("duration.hours \(String($0))") }
return field("disk.powerOnShort", value: hours ?? Text(verbatim: "--"))
}
private func field(_ title: LocalizedStringKey, value: String) -> some View { private func field(_ title: LocalizedStringKey, value: Text) -> some View {
HStack(spacing: 3) { HStack(spacing: 3) {
Text(title).foregroundStyle(.secondary).help(Text(title)) Text(title).foregroundStyle(.secondary).help(Text(title))
MetricText(value: value).fontWeight(.medium).foregroundStyle(.primary) value.monospacedDigit().fontWeight(.medium).foregroundStyle(.primary)
}.frame(height: 14) }.frame(height: 14)
} }
} }
+128 -18
View File
@@ -1,6 +1,94 @@
{ {
"sourceLanguage" : "en", "sourceLanguage" : "en",
"strings" : { "strings" : {
"duration.hours %@": {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "%@ h"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "%@ 小时"
}
},
"zh-Hant": {
"stringUnit": {
"state": "translated",
"value": "%@ 小時"
}
}
}
},
"duration.minutes %lld": {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "%lld min"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "%lld 分钟"
}
},
"zh-Hant": {
"stringUnit": {
"state": "translated",
"value": "%lld 分鐘"
}
}
}
},
"memory.used": {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Memory used"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "已用内存"
}
},
"zh-Hant": {
"stringUnit": {
"state": "translated",
"value": "已用記憶體"
}
}
}
},
"gpu.oneCore": {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "1 core"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "1 核"
}
},
"zh-Hant": {
"stringUnit": {
"state": "translated",
"value": "1 核心"
}
}
}
},
"power.charging": { "power.charging": {
"localizations": { "localizations": {
"en": { "en": {
@@ -238,7 +326,7 @@
"zh-Hant": { "zh-Hant": {
"stringUnit": { "stringUnit": {
"state": "translated", "state": "translated",
"value": "應用包含應用和系統程序使用的匿名記憶體;連動包含核心、驅動等常駐記憶體;壓縮為壓縮器的實際實體佔用。可回收快取計入可用空間,磁碟 Swap 不再疊加到實體記憶體已用量。" "value": "App 記憶體包含 App 與系統程序使用的匿名記憶體。系統核心記憶體包含核心與驅動程式等必須常駐的記憶體。壓縮欄顯示壓縮後實際佔用的實體記憶體。可回收的快取計入可用記憶體,磁碟上的交換空間另計。"
} }
} }
} }
@@ -270,7 +358,7 @@
"en": { "en": {
"stringUnit": { "stringUnit": {
"state": "translated", "state": "translated",
"value": "On-time" "value": "Power-on"
} }
}, },
"zh-Hans": { "zh-Hans": {
@@ -336,19 +424,41 @@
"en": { "en": {
"stringUnit": { "stringUnit": {
"state": "translated", "state": "translated",
"value": "Time" "value": "Time left"
} }
}, },
"zh-Hans": { "zh-Hans": {
"stringUnit": { "stringUnit": {
"state": "translated", "state": "translated",
"value": "估时" "value": "剩余时间"
} }
}, },
"zh-Hant": { "zh-Hant": {
"stringUnit": { "stringUnit": {
"state": "translated", "state": "translated",
"value": "估時" "value": "剩餘時間"
}
}
}
},
"battery.timeToFull" : {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Time to full"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "距充满"
}
},
"zh-Hant": {
"stringUnit": {
"state": "translated",
"value": "距充滿"
} }
} }
} }
@@ -392,7 +502,7 @@
"zh-Hant": { "zh-Hant": {
"stringUnit": { "stringUnit": {
"state": "translated", "state": "translated",
"value": "應用" "value": "App"
} }
} }
} }
@@ -414,7 +524,7 @@
"zh-Hant": { "zh-Hant": {
"stringUnit": { "stringUnit": {
"state": "translated", "state": "translated",
"value": "連動" "value": "系統核心"
} }
} }
} }
@@ -1678,19 +1788,19 @@
"en" : { "en" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "Measured intervals / enumerated processes: %1$lld / %2$lld" "value" : "Processes with a CPU power reading: %1$lld of %2$lld enumerated"
} }
}, },
"zh-Hans" : { "zh-Hans" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "有效区间进程数 / 枚举数:%1$lld / %2$lld" "value" : "已测得 CPU 功率的进程:%1$lld / %2$lld"
} }
}, },
"zh-Hant" : { "zh-Hant" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "有效區間程序數 / 列舉數:%1$lld / %2$lld" "value" : "已測得 CPU 功率的程序:%1$lld / %2$lld"
} }
} }
} }
@@ -1828,7 +1938,7 @@
"zh-Hant" : { "zh-Hant" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "%d 核" "value" : "%d 核心"
} }
} }
} }
@@ -2051,7 +2161,7 @@
"zh-Hant" : { "zh-Hant" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "應用程式記憶體" "value" : "App 記憶體"
} }
} }
} }
@@ -2212,7 +2322,7 @@
"zh-Hant" : { "zh-Hant" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "連動記憶體" "value" : "系統核心記憶體"
} }
} }
} }
@@ -2623,19 +2733,19 @@
"en" : { "en" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "APFS volumes may share capacity; do not add totals." "value" : "APFS volumes may share capacity. Summing them can count the same space twice."
} }
}, },
"zh-Hans" : { "zh-Hans" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "APFS 卷可能共享容量,不合算总量。" "value" : "APFS 卷可能共享容量,直接相加会重复计算。"
} }
}, },
"zh-Hant" : { "zh-Hant" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "APFS 卷宗可能共用容量,不加總。" "value" : "APFS 卷宗可能共用容量,直接加總會重複計算。"
} }
} }
} }
@@ -3157,13 +3267,13 @@
"zh-Hans" : { "zh-Hans" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "开机时间" "value" : "运行时长"
} }
}, },
"zh-Hant" : { "zh-Hant" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "開機時間" "value" : "運作時間"
} }
} }
} }
+17 -3
View File
@@ -1,8 +1,10 @@
"""Validate catalog coverage and printf argument compatibility against zh-Hans.""" """Validate catalog coverage and printf argument compatibility in the source catalogs and optionally the compiled app."""
import argparse
import collections import collections
import json import json
from pathlib import Path from pathlib import Path
import re import re
import subprocess
root = Path(__file__).resolve().parents[1] / 'kymo/Resources' root = Path(__file__).resolve().parents[1] / 'kymo/Resources'
pattern = re.compile(r'%(?:(\d+)\$)?[-+#0 ]*(?:\d+)?(?:\.\d+)?(ll|l|h)?([@diuoxXfFeEgGcCsSp])') pattern = re.compile(r'%(?:(\d+)\$)?[-+#0 ]*(?:\d+)?(?:\.\d+)?(ll|l|h)?([@diuoxXfFeEgGcCsSp])')
@@ -13,13 +15,25 @@ def arguments(text):
result[(int(match[1] or index), (match[2] or '') + match[3])] += 1 result[(int(match[1] or index), (match[2] or '') + match[3])] += 1
return result return result
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--app', type=Path, help='Also compare every translation with the built app')
app = parser.parse_args().app
locales = ('zh-Hans', 'en', 'zh-Hant')
count = 0 count = 0
for path in sorted(root.glob('*.xcstrings')): for path in sorted(root.glob('*.xcstrings')):
compiled = {}
if app:
for locale in locales:
table = app / 'Contents' / 'Resources' / f'{locale}.lproj' / f'{path.stem}.strings'
compiled[locale] = json.loads(subprocess.check_output(['plutil', '-convert', 'json', '-o', '-', table]))
for key, entry in json.loads(path.read_text())['strings'].items(): for key, entry in json.loads(path.read_text())['strings'].items():
units = {locale: entry['localizations'][locale]['stringUnit'] units = {locale: entry['localizations'][locale]['stringUnit']
for locale in ['zh-Hans', 'en', 'zh-Hant']} for locale in locales}
expected = arguments(key) or arguments(units['en']['value'])
for locale, unit in units.items(): for locale, unit in units.items():
assert unit['state'] == 'translated' and unit['value'].strip(), (path, key, locale) assert unit['state'] == 'translated' and unit['value'].strip(), (path, key, locale)
assert arguments(unit['value']) == arguments(units['zh-Hans']['value']), (path, key, locale) assert arguments(unit['value']) == expected, (path, key, locale)
if app:
assert compiled[locale].get(key) == unit['value'], (path, key, locale, 'built translation')
count += 1 count += 1
print(f'PASS: {count} catalog entries, three-language coverage and format arguments') print(f'PASS: {count} catalog entries, three-language coverage and format arguments')
+6 -1
View File
@@ -36,7 +36,12 @@ import Foundation
let expected = ["en": "Fan", "zh-Hans": "风扇", "zh-Hant": "風扇"][language]! let expected = ["en": "Fan", "zh-Hans": "风扇", "zh-Hant": "風扇"][language]!
precondition(title == "\(expected) \(number)", "Numbered fan must use the selected app locale") precondition(title == "\(expected) \(number)", "Numbered fan must use the selected app locale")
} }
let minutes = AppLocalization.string("duration.minutes %lld", locale: locale, bundle: bundle)
let hours = AppLocalization.string("duration.hours %@", locale: locale, bundle: bundle)
let durations = [String(format: minutes, Int64(45)), String(format: hours, "1.5")]
let expectedDurations = ["en": ["45 min", "1.5 h"], "zh-Hans": ["45 分钟", "1.5 小时"],
"zh-Hant": ["45 分鐘", "1.5 小時"]]
precondition(durations == expectedDurations[language])
} }
print("PASS: system matching, explicit override, fallback, preference roundtrip, built three-language resources") print("PASS: system matching, explicit override, fallback, preference roundtrip, built three-language resources")
} }
+1 -1
View File
@@ -199,7 +199,7 @@ def main():
print(line, flush=True) print(line, flush=True)
app = work / "build/Build/Products" / args.configuration / "kymo.app" app = work / "build/Build/Products" / args.configuration / "kymo.app"
host_entitlements = entitlements(app) host_entitlements = entitlements(app)
run([sys.executable, "kymoTests/LocalizationCatalogChecks.py"]) run([sys.executable, "kymoTests/LocalizationCatalogChecks.py", "--app", app])
for index, name in enumerate(selected, 1): for index, name in enumerate(selected, 1):
print(f"[{index}/{len(selected)}] {name}", flush=True) print(f"[{index}/{len(selected)}] {name}", flush=True)
executable = work / name executable = work / name