Repository navigation
fix(i18n): join catalog sentences with joinSentences so zh text doesn't run together - #50434
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…'t run together Several desktop and mobile notices joined two catalog sentences with a plain space. zh catalog values drop their final stop, so the sentences ran together; zh-Hant and ja got a stray space after the stop. Route those call sites through joinSentences, which now also skips empty pieces and places the stop after a trailing CJK closer or curly quote (ASCII closers keep their space so English text is unchanged). Refs stablyai#32207
aa0ff59 to
d7f096f
Compare
ELI5
Some notices are built by gluing two sentences from the translation catalog together with a space. Chinese catalog values leave off the final
。, so in Chinese the two sentences ran together: 「…且此电脑能访问其地址 这是 Tailscale 地址…」. Traditional Chinese and Japanese keep their。, but still got a stray space after it. This PR sends those pieces through the sharedjoinSentenceshelper, which puts。between Chinese sentences and keeps the space in English.What Changed
Before: these surfaces joined sentences with
${a} ${b},{a}{' '}{b}or.join(' '):After: each one calls
joinSentences(src/shared/text/sentence-joining.ts), which the desktop write notices already used. zh gets。between sentences. zh-Hant and ja lose the stray space after。. English output is byte-identical.Helper changes:
joinSentencesskips empty pieces, so optional sentences can be passed as''without adding a leading, trailing or doubled separator.”’」』)】》〉), the helper looks just inside it.…(安全的默认设置)+选择…now joins as…(安全的默认设置)。选择…instead of…) 选择….' " ) ]) work as they do onmain, so an English sentence that ends in an ASCII-quoted CJK path (scandir '/Users/x/项目') keeps its space./[…]+$/, which avoids quadratic backtracking on long closer runs.The phone skills note moved into
botSkillsListedNoteinmobile-bot-sheet-copy.ts, which keeps the skills page under the line limit.Why
Linked Issue
Refs #32207 (localization tracking issue; this fixes a subset of the call sites)
Visual Proof
Before/after fixture renders from the original PR, on macOS:
Testing
Reproduced on
mainwith a scratch script that loads the real en, zh, zh-Hant, ja and ko catalogs (desktop and mobile) and compares the old space join withjoinSentencesat each call site:main, and each gets。with this PR.。is gone.src/shared/text/sentence-joining.test.ts(new, 4 cases, all fail on the old helper): a closer that ends a zh sentence, a stop inside a closer, an ASCII-quoted path ending in CJK keeps its space, and empty pieces are skipped.Unit tests:
viteston sentence-joining and the image gallery folder pass (3 files, 18 tests). Tested on macOS.On the 15 touched files: oxlint, oxfmt, the anti-slop and code-quality oxlint configs, ast-grep, and the changed-code quality gate are all clean.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Call-site copy is not asserted in tests, per test-antipatterns.md. The helper is the contract.
Performance
None that matters. The strings are built at render time only, with no I/O, polling or subscriptions. The hottest former caller, the palette status that updated on every keystroke, is not touched. Microbenchmark of
joinSentences,mainvs this PR (tsx, Node 24):The adversarial case is unrealistic (catalog strings are about 100 characters), scales linearly, and stays far under 16 ms.
Risk
Level: Low
。!?, or one with CJK text and no final punctuation.joinSentencescallers: empty pieces no longer produce a doubled, leading or trailing separator.。. No current caller does this.Agent skill upstream boundary
Notes
Original fix by @x-Ai in #50434; maintainer review follow-ups were squashed into this branch with authorship preserved.
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance