refactor(frontend): pluralize reading-control counts via paraglide#843
Merged
Conversation
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: Combined Review (
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #839, which merged before this cleanup landed.
The session reading-control count labels did their own pluralization in JS: a
callUnithelper, paired_singular/_pluralmessages, and atotalCalls === 1ternary inToolCallGroup. 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 declaresone/other; zh-CN declares the single form it actually needs. Counts are now passed as numbers soIntl.PluralRulespicks the category.parallel_group_call_countandsubagent_inline_message_count, which previously always rendered the plural form, are pluralized too.Reviewers: the substance is in
messages/en.jsonandmessages/zh-CN.json; the four components just drop their manual plural logic and pass a numericcount.Duration formatting deliberately stays in the
formatDurationhelper — Paraglide only shipsdatetime/relativetime/numbermatchers, 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