Skip to content

refactor(frontend): pluralize reading-control counts via paraglide#843

Merged
wesm merged 1 commit into
mainfrom
refactor/i18n-pluralize-counts
Jun 24, 2026
Merged

refactor(frontend): pluralize reading-control counts via paraglide#843
wesm merged 1 commit into
mainfrom
refactor/i18n-pluralize-counts

Conversation

@mariusvniekerk

Copy link
Copy Markdown
Collaborator

Follow-up to #839, which merged before this cleanup landed.

The session reading-control count labels did their own pluralization in JS: a callUnit helper, paired _singular/_plural messages, and a totalCalls === 1 ternary in ToolCallGroup. That bakes English's two-form (one/other) assumption into the call sites, so other locales can't express their own plural rules — Simplified Chinese, which has no count-based plural distinction, was forced to ship duplicate identical "singular" and "plural" strings.

This moves the cardinal selection into the Paraglide message variants (local countPlural = count: plural). English declares one/other; zh-CN declares the single form it actually needs. Counts are now passed as numbers so Intl.PluralRules picks the category. parallel_group_call_count and subagent_inline_message_count, which previously always rendered the plural form, are pluralized too.

Reviewers: the substance is in messages/en.json and messages/zh-CN.json; the four components just drop their manual plural logic and pass a numeric count.

Duration formatting deliberately stays in the formatDuration helper — Paraglide only ships datetime/relativetime/number matchers, none of which produce the compact elapsed-time format ("2m 30s") these controls use.

Out of scope: relative timestamps (formatRelativeTime, the sidebar "5m ago" labels) are still hardcoded English and not routed through i18n at all; localizing those is a separate follow-up.

generated by a clanker

Count labels in the reading controls did their own pluralization in JS: a `callUnit` helper, paired `_singular`/`_plural` messages, and a `totalCalls === 1` ternary. That approach bakes English's two-form (one/other) assumption into the call sites, so other locales can't express their own plural rules. Simplified Chinese, for instance, has no count-based plural distinction and was forced to ship duplicate "singular" and "plural" strings.

Paraglide's message format supports cardinal pluralization natively, so the one/other selection now lives in the message variants (`local countPlural = count: plural`). English declares one/other; zh-CN declares the single form it actually needs. Counts are passed as numbers so Intl.PluralRules selects the right category.

Duration formatting stays in the `formatDuration` helper: Paraglide only ships datetime/relativetime/number matchers, none of which produce the compact elapsed-time format ("2m 30s") the controls use.
@roborev-ci

roborev-ci Bot commented Jun 24, 2026

Copy link
Copy Markdown

roborev: Combined Review (570c67e)

No issues found.


Panel: ci_default_security | Synthesis: codex | Members: codex_default (codex/default, done, 2m42s), codex_security (codex/security, done, 37s) | Total: 3m19s

@wesm wesm merged commit 00b50fe into main Jun 24, 2026
23 checks passed
@wesm wesm deleted the refactor/i18n-pluralize-counts branch June 24, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants