From 918cd4a25239c6c7c208d64b710cb8e78b4cbb1b Mon Sep 17 00:00:00 2001 From: AAA <35992542+TNTcraftHIM@users.noreply.github.com> Date: Sat, 14 Nov 2026 11:07:18 -0400 Subject: [PATCH] fix(i18n): align language selection and native labels --- docs/guide/translating.md | 7 ++-- docs/guide/translating.zh-CN.md | 5 ++- docs/standards/presentation-lifecycle.md | 4 +- prototype/channel-server/src/app_windows.rs | 32 +++++++++++---- .../components/living/LanguageControl.tsx | 2 +- .../components/living/segmented-control.css | 4 +- src/client/styles.css | 2 +- src/client/ui/native-window-caption.html | 2 +- src/client/ui/native-window.ts | 3 +- src/client/ui/window-controls.json | 39 +++++++++++++++++++ tests/native-window.test.ts | 30 ++++++++++++++ 11 files changed, 110 insertions(+), 20 deletions(-) create mode 100644 tests/native-window.test.ts diff --git a/docs/guide/translating.md b/docs/guide/translating.md index c8e6681e7..a9801e38a 100644 --- a/docs/guide/translating.md +++ b/docs/guide/translating.md @@ -125,9 +125,10 @@ layout questions, so contributors can coordinate work and review. System tags `zh-CN` and `zh-Hans` select Simplified Chinese; `zh-TW`, `zh-HK` and `zh-Hant` select Traditional Chinese. Saved explicit choices take precedence over -system defaults, and App handoff carries the registered language tag. The native -console supports Chinese/English with English fallback for other languages; -native window captions have their own Chinese/English text. +system defaults, and App handoff carries the registered locale. The native +console supports Chinese/English with English fallback for other languages. +Windows window controls and permission prompts use the same five languages; +their shared labels live in [window-controls.json](../../src/client/ui/window-controls.json). ## Playful copy diff --git a/docs/guide/translating.zh-CN.md b/docs/guide/translating.zh-CN.md index be39fdcd2..43626d007 100644 --- a/docs/guide/translating.zh-CN.md +++ b/docs/guide/translating.zh-CN.md @@ -99,8 +99,9 @@ App 启动错误需同步修改共用启动页与错误说明,保留 Rust 运 从右向左书写的语言还需实现并检查文字方向与布局。 系统标签 `zh-CN`、`zh-Hans` 选择简体中文,`zh-TW`、`zh-HK`、`zh-Hant` 选择繁體中文。 -已保存的显式选择优先于系统默认值,App 跳转携带登记的语言标签。原生终端支持中英文, -其他语言回退英文;原生窗口标题独立维护中英文文案。 +已保存的显式选择优先于系统默认值,App 跳转携带登记的语言。原生终端支持中英文, +其他语言回退英文。Windows 窗口控件和权限提示使用相同的五种语言,共用文案位于 +[window-controls.json](../../src/client/ui/window-controls.json)。 ## 俏皮话 diff --git a/docs/standards/presentation-lifecycle.md b/docs/standards/presentation-lifecycle.md index b8958e361..3fd0a09d2 100644 --- a/docs/standards/presentation-lifecycle.md +++ b/docs/standards/presentation-lifecycle.md @@ -172,8 +172,8 @@ Explicit launcher choices apply only to the presentation domains the user chose. Older launchers cannot distinguish defaults from explicit choices; updated Sites preserve their saved preferences when receiving those unmarked hints. The App console supports Chinese and English: both Chinese catalogs use Chinese, -and other UI languages fall back to English. Native window captions have their -own Chinese/English presentation. The public website, film and documentation +and other UI languages fall back to English. Windows window controls and +permission prompts use the shared UI's five languages. The public website, film and documentation maintain independent Chinese/English content. All UI languages use concise copy. The [visual language](./visual-language.md) is the single owner of diff --git a/prototype/channel-server/src/app_windows.rs b/prototype/channel-server/src/app_windows.rs index f9e45a1e5..485a6aa7b 100644 --- a/prototype/channel-server/src/app_windows.rs +++ b/prototype/channel-server/src/app_windows.rs @@ -53,12 +53,19 @@ extern "system" { enum Language { En, Zh, + #[serde(rename = "zh-Hant")] + ZhHant, + Ja, + Ko, } impl Language { fn code(self) -> &'static str { match self { Self::En => "en", Self::Zh => "zh", + Self::ZhHant => "zh-Hant", + Self::Ja => "ja", + Self::Ko => "ko", } } } @@ -119,6 +126,10 @@ struct WindowControls { struct Labels { en: WindowCopy, zh: WindowCopy, + #[serde(rename = "zh-Hant")] + zh_hant: WindowCopy, + ja: WindowCopy, + ko: WindowCopy, } #[derive(Deserialize)] #[serde(rename_all = "camelCase")] @@ -133,6 +144,9 @@ impl WindowControls { match language { Language::En => &self.labels.en, Language::Zh => &self.labels.zh, + Language::ZhHant => &self.labels.zh_hant, + Language::Ja => &self.labels.ja, + Language::Ko => &self.labels.ko, } } } @@ -515,6 +529,11 @@ pub fn run(mut config: Config, port: Option) -> Result<()> { } else if let Some(launcher) = &launcher_url { let mut url = url::Url::parse(launcher).expect("Local App entry"); url.query_pairs_mut().append_pair("bookmarks", "1"); + let mut fragment = + url::form_urlencoded::Serializer::new(String::new()); + fragment + .append_pair("piik-client", "1") + .append_pair("piik-lang", language.code()); if let Some(current) = main .content .url() @@ -524,16 +543,13 @@ pub fn run(mut config: Config, port: Option) -> Result<()> { if matches!(current.scheme(), "http" | "https") && current.origin() != url.origin() { - let fragment = - url::form_urlencoded::Serializer::new(String::new()) - .append_pair( - "site", - ¤t.origin().ascii_serialization(), - ) - .finish(); - url.set_fragment(Some(&fragment)); + fragment.append_pair( + "site", + ¤t.origin().ascii_serialization(), + ); } } + url.set_fragment(Some(&fragment.finish())); match BookmarksWindow::new( target, &mut context, diff --git a/src/client/components/living/LanguageControl.tsx b/src/client/components/living/LanguageControl.tsx index 547c1d2da..f9461a9c0 100644 --- a/src/client/components/living/LanguageControl.tsx +++ b/src/client/components/living/LanguageControl.tsx @@ -79,8 +79,8 @@ export function LanguageControl() { > + button { min-width: 0; padding: 0; } +.lr-lang > .lr-lang-more { display: grid; grid-template-columns: var(--selection-item-size) 12px; gap: 0; } .lr-toggle button, .lr-lang > button { cursor: pointer; } .lr-toggle button:disabled, .lr-lang > button:disabled { cursor: default; } .lr-toggle > label { position: relative; min-width: 0; } diff --git a/src/client/styles.css b/src/client/styles.css index 01a63a6b5..66481de65 100644 --- a/src/client/styles.css +++ b/src/client/styles.css @@ -170,7 +170,7 @@ ul { margin: 0; padding: 0; list-style: none; } @keyframes lr-blink { 50% { opacity: .3; } } /* Extra locales share one menu after the familiar shortcuts. */ -.lr-lang-more > span { display: inline-flex; align-items: center; gap: 2px; pointer-events: none; } +.lr-lang-more > span { display: inline-flex; align-items: center; justify-content: center; pointer-events: none; } .lr-lang-more .lr-glyph:last-child { transition: transform var(--motion-control) var(--spring); } .lr-header-controls:has(.lr-language-menu:is(:popover-open, .\:popover-open)) .lr-lang-more .lr-glyph:last-child { transform: rotate(180deg); } .lr-language-menu { diff --git a/src/client/ui/native-window-caption.html b/src/client/ui/native-window-caption.html index 1b2f5e61e..1f818d054 100644 --- a/src/client/ui/native-window-caption.html +++ b/src/client/ui/native-window-caption.html @@ -19,7 +19,7 @@ svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: