refactor(i18n): 迁移到 rust-i18n 语义键体系(ns.key),废弃中文原文作 key
旧实现的问题(按用户反馈):
- 中文原文作 key:文案措辞与代码耦合,一词多义撞 key("主题" Topic/Theme)
- 巨型 match 文案表:重复键靠编译警告暴露;漏翻静默回退,无任何校验
- tf 参数到处 &n.to_string() 噪音
新体系(gpui-kit 官方方案):
- locales/ui.yml 语言包(rust-i18n v2,en/zh-CN 双语并排),key 为
语义标识符(common.save / conn.connect / status.connected…),
与自然语言彻底解耦;改措辞不动代码
- crate 根 i18n! 编译期内嵌;init_i18n() 经 extend! 并入 gpui-kit
组件内置文案(按钮/空态等随语言切换)
- t/tf 薄门面查 _rust_i18n_translate(运行时 key),模型 label()
改返回语义 key;tf 参数只需 Display
- 四个强制单测:语言包 en/zh-CN 完整、占位符 {x} 两侧一致、
全源码 t()/tf() 字面量必须存在词条、模型 label 必须有真实译文
- 语言中性文案("QoS"、"/mqtt" 等)去掉 t() 包裹
- 顺带补翻 30 条漏网文案(资源监控统计行/表单校验/阿里云说明段等)
42 测试全绿;中英双语实机截图验证零裸 key。
This commit is contained in:
@@ -80,8 +80,8 @@ impl MqttXApp {
|
||||
Notification::success(i18n::tf(
|
||||
"导出 {n} 条连接到 {path}",
|
||||
&[
|
||||
("n", &count.to_string()),
|
||||
("path", &path.display().to_string()),
|
||||
("n", &count),
|
||||
("path", &path.display()),
|
||||
],
|
||||
)),
|
||||
cx,
|
||||
@@ -136,8 +136,8 @@ impl MqttXApp {
|
||||
Notification::success(i18n::tf(
|
||||
"导入 {n} 条,跳过 {n2} 条",
|
||||
&[
|
||||
("n", &added.to_string()),
|
||||
("n2", &skipped.to_string()),
|
||||
("n", &added),
|
||||
("n2", &skipped),
|
||||
],
|
||||
)),
|
||||
cx,
|
||||
|
||||
Reference in New Issue
Block a user