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:
@@ -17,8 +17,8 @@ pub enum Direction {
|
||||
impl Direction {
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
Self::Received => "接收",
|
||||
Self::Published => "发布",
|
||||
Self::Received => "dir.received",
|
||||
Self::Published => "dir.published",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ pub enum ConnectionStatus {
|
||||
impl ConnectionStatus {
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
Self::Disconnected => "未连接",
|
||||
Self::Connecting => "连接中",
|
||||
Self::Connected => "已连接",
|
||||
Self::Error => "错误",
|
||||
Self::Disconnected => "status.disconnected",
|
||||
Self::Connecting => "status.connecting",
|
||||
Self::Connected => "status.connected",
|
||||
Self::Error => "status.error",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,9 +42,9 @@ impl ThemeModePref {
|
||||
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
Self::System => "跟随系统",
|
||||
Self::Light => "浅色",
|
||||
Self::Dark => "深色",
|
||||
Self::System => "theme.system",
|
||||
Self::Light => "theme.light",
|
||||
Self::Dark => "theme.dark",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user