Skip to content

fix(i18n): join catalog sentences with joinSentences so zh text doesn't run together - #50434

Merged
nwparker merged 1 commit into
stablyai:mainfrom
x-Ai:fix/i18n-join-sentences
Nov 27, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
x-Ai:fix/i18n-join-sentences

Conversation

@x-Ai

@x-Ai x-Ai commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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 shared joinSentences helper, 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(' '):

  • Desktop: unreachable server hint, plugin remove dialog, WSL move progress, AI vault empty-session note, image gallery step announcement, terminal "Option as Alt" description, cookie import on a paired page, Google disconnect confirmation
  • Phone: write notices, Google disconnect confirmation, GitHub connect footer, skills note

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:

  • joinSentences skips empty pieces, so optional sentences can be passed as '' without adding a leading, trailing or doubled separator.
  • When a CJK sentence ends on a full-width closer or curly quote (”’」』)】》〉), the helper looks just inside it. …(安全的默认设置) + 选择… now joins as …(安全的默认设置)。选择… instead of …) 选择….
  • ASCII closers (' " ) ]) work as they do on main, so an English sentence that ends in an ASCII-quoted CJK path (scandir '/Users/x/项目') keeps its space.
  • The closer trim is a loop rather than /[…]+$/, which avoids quadratic backtracking on long closer runs.

The phone skills note moved into botSkillsListedNote in mobile-bot-sheet-copy.ts, which keeps the skills page under the line limit.

Why

  • Two sentences with no stop between them read as a typo, and Chinese has no capital letter to mark where the second one starts.
  • Fixing this in one helper instead of editing catalog values keeps the catalog convention of dropping final stops. Both languages also stay right when a value gains or loses its stop.
  • The worktree palette's aria-live status was left as separate text nodes, so screen readers still announce only the part that changed.

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:

Screen Upstream main This PR
Plugin remove dialog plugin remove dialog on main plugin remove dialog with this PR
WSL move progress WSL move progress on main WSL move progress with this PR
Option as Alt (terminal settings) Option as Alt on main Option as Alt with this PR

Testing

  • Reproduced on main with a scratch script that loads the real en, zh, zh-Hant, ja and ko catalogs (desktop and mobile) and compares the old space join with joinSentences at each call site:

    • zh: every site ran together on main, and each gets 。 with this PR.
    • zh-Hant and ja: the stray space after 。 is gone.
    • en and ko: unchanged ("english mismatches: 0").
  • 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: vitest on 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, main vs this PR (tsx, Node 24):

Input main This PR
en, 3 sentences 100 ns 71 ns
zh pair 110 ns 89 ns
zh ending in ) 124 ns 119 ns
sentence + empty piece 59 ns 6 ns
adversarial 100k trailing ) 0.02 ms 1.4 ms

The adversarial case is unrealistic (catalog strings are about 100 characters), scales linearly, and stays far under 16 ms.

Risk

Level: Low

  • English UI is unchanged. Separators only change after a sentence that ends in 。!?, or one with CJK text and no final punctuation.
  • The behavior change for other joinSentences callers: empty pieces no longer produce a doubled, leading or trailing separator.
  • Known edge case: an English sentence with no final stop that ends in a curly-quoted or full-width-bracketed CJK value would get 。. No current caller does this.
  • Back out with a plain revert.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The shared joinSentences helper now handles trailing CJK closing marks and curly quotes when selecting separators, and skips empty sentences. Mobile and renderer components use the helper to combine notices, confirmation text, setting descriptions, and announcements. The mobile bot skills page now uses a localized note assembled by botSkillsListedNote. Tests cover closing-mark punctuation, quoted paths, and empty sentences.

Merge Risk: Minimal · up to d7f09

This change fixes sentence spacing and punctuation in Chinese, Japanese, and Traditional Chinese UI text and leaves English output unchanged. No concrete defect was found, and the added helper tests cover the new separator cases, so the merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: replacing literal-space sentence joins with the shared joinSentences helper so Chinese sentences get a full stop between them. The changeset matches this across deskto…
Description check Passed The description follows the template closely: ELI5, What Changed (before and after), Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure (left as template, which is acceptable f…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: replacing literal-space sentence joins with the shared joinSentences helper so Chinese sentences get a full stop between them. The changeset matches this across desktop and mobile call sites and the helper. The title is specific and reads as a fix, with a scoped prefix.

Full details: Description check

Explanation

The description follows the template closely: ELI5, What Changed (before and after), Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure (left as template, which is acceptable for maintainers), Agent skill boundary, and Notes. It explains the mechanism, the edge cases, and the back-out path. The Linked Issue is a tracking reference (Refs #32207, fixes a subset), which the template says is not enough for outside contributors. The Visual Proof images link to a fork's raw URLs and the Testing checkboxes leave manual testing unchecked. The Risk level is set, and the Performance line is filled in.

Resolution

Optional: confirm the contributor status for the Linked Issue rule, since the description cites a tracking issue (Refs #32207) rather than a closing link. Consider checking the manual-testing box or noting the platforms tested beyond macOS, and confirm the image URLs resolve from the main repository.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 34bbef79-59dc-41c1-af54-35e2d64ef2a1
Commits

Reviewing files that changed from the base of the PR and between c9cac62 and d7f096f.

Files selected for processing: 14

  • mobile/src/bots/connectors/MobileBotGitHubSetup.tsx
  • mobile/src/bots/connectors/phone-google-accounts.tsx
  • mobile/src/bots/mobile-bot-sheet-copy.ts
  • mobile/src/bots/skills/MobileBotSkills.tsx
  • src/renderer/src/components/bots/google/GoogleAccountRow.tsx
  • src/renderer/src/components/native-chat/media/images/gallery/NativeChatImageGallery.tsx
  • src/renderer/src/components/plugins/dialogs/PluginRemoveDialog.tsx
  • src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionUnsavedNotice.tsx
  • src/renderer/src/components/settings/browser/profiles/BrowserCookieImportMachineNotice.tsx
  • src/renderer/src/components/settings/runtime-environments/server-rows/runtime-server-row-details.tsx
  • src/renderer/src/components/settings/terminal/platform/TerminalMacKeyboardSection.tsx
  • src/renderer/src/components/wsl-move/WslMoveProgressBody.tsx
  • src/shared/text/sentence-joining.test.ts
  • src/shared/text/sentence-joining.ts
Files skipped from review as they are similar to previous changes: 4

  • mobile/src/bots/mobile-bot-sheet-copy.ts
  • src/renderer/src/components/bots/google/GoogleAccountRow.tsx
  • src/renderer/src/components/settings/browser/profiles/BrowserCookieImportMachineNotice.tsx
  • src/renderer/src/components/settings/terminal/platform/TerminalMacKeyboardSection.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

…'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
@nwparker
nwparker force-pushed the fix/i18n-join-sentences branch from aa0ff59 to d7f096f Compare November 27, 2026 06:01
@nwparker nwparker changed the title fix(i18n): join catalog sentences so zh text doesn't run together fix(i18n): join catalog sentences with joinSentences so zh text doesn't run together Nov 27, 2026
@nwparker
nwparker merged commit d422121 into stablyai:main Nov 27, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants