Repository navigation
refactor(i18n): native i18next plurals at call sites, plural-aware extraction - #35637
Conversation
…plural fill
Each catalog load parsed the JSON, rebuilt it to fill CLDR plural forms
from _other, then deep-copied and deep-merged it into the store (about
26 ms after parsing per 1.3 MB catalog), and concurrent loads of one
locale fetched it twice.
- sync:localization-catalog now commits the plural forms a locale's
CLDR rules need beside each _other (fr/es/pt many, tr one, a few
de/ru), and verify:localization-catalog fails when one is missing.
Plural forms may include {{count}} where English omits it.
- Renderer and main load built-in catalogs as-is; plugin packs keep the
runtime fill.
- Renderer catalog requests are shared per locale; a timed-out request
is dropped so a retry fetches again. Bundles are added with skipCopy.
- createOrcaI18n (src/shared/orca-i18n-instance.ts) owns the backend, init options, plugin-pack registration, resource-language resolution and the translate wrapper; main and renderer inject only how a built-in catalog loads (dynamic import vs. fetch) and extra modules. - Remove setRendererUiLanguage (tests only); tests load then switch. - resolveUiLocale maps built-ins by lookup instead of an if-chain, and catalog URLs/loaders are direct map lookups. - Drop <I18nextProvider>: initReactI18next already binds the instance.
# Conflicts: # src/main/i18n/main-i18n.ts
…traction
Call sites branched on count === 1 and passed literal _one/_other keys,
which resolvePluralFamilyKey stripped again so CLDR could pick the form.
They now call translate('x', otherDefault, { count, defaultValue_one })
and i18next selects the form natively; catalog keys stay x_one/x_other.
- Converted 284 families with an AST codemod plus a few by hand; added
defaultValue_one to 21 base-key families that relied on en.json.
- Extraction runs with plurals enabled, so both English defaults are
checked for drift. A key that only fills {{count}} (no defaultValue_one)
stays singular in en.json.
- verify/sync:localization-catalog expand a native plural call into its
x_one/x_other English entries.
- Removed 22 base keys that a sibling plural family shadowed in every
catalog.
…nt for plural refs
# Conflicts: # config/scripts/locale-plural-forms.mjs # config/scripts/verify-localization-catalog.mjs # config/scripts/verify-localization-catalog.test.mjs # src/renderer/src/i18n/lazy-locale.test.ts # src/renderer/src/i18n/locales/es.json # src/renderer/src/i18n/locales/fr.json # src/renderer/src/i18n/locales/pt.json # src/shared/orca-i18n-instance.ts
…efault plural extraction as dynamic
…ey-as-default is dynamic
[Medium impact] The PR appears safe to merge; no blocking issues were found. SummaryMoves plural calls to base keys with
No actionable issues were found. Tests were inspected but not run.
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 17 minutes. View limit details
No actionable comments were generated in the recent review.
|
There was a problem hiding this comment.
Actionable comments posted: 1

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:
d0f949e4-416c-48cc-aa94-8773bb9c69fe
Files selected for processing: 185-
config/i18next.config.tsconfig/scripts/locale-plural-forms.mjsconfig/scripts/verify-localization-catalog.mjsconfig/scripts/verify-localization-catalog.test.mjsconfig/scripts/verify-localization-extraction.mjsconfig/scripts/verify-localization-extraction.test.mjssrc/main/i18n/main-i18n-lazy-locale.test.tssrc/main/local-builds/local-build-switch.tssrc/renderer/src/components/ClaudeAccountSwitchDialog.tsxsrc/renderer/src/components/JiraLinkedWorkspaceAction.tsxsrc/renderer/src/components/NativeChatRemoteResumeActions.tsxsrc/renderer/src/components/NativeChatResumeOnRestartModal.tsxsrc/renderer/src/components/NativeChatResumeRunPanel.tsxsrc/renderer/src/components/QuickOpen.tsxsrc/renderer/src/components/activity/ActivityTitlebarControls.tsxsrc/renderer/src/components/activity/activity-clear-completed.tssrc/renderer/src/components/activity/activity-thread-context-menu.tsxsrc/renderer/src/components/automations/AutomationDetail.tsxsrc/renderer/src/components/automations/AutomationListLocalRow.tsxsrc/renderer/src/components/automations/AutomationRunHistory.tsxsrc/renderer/src/components/automations/ExternalAutomationManagers.tsxsrc/renderer/src/components/automations/automation-run-occurrences.tssrc/renderer/src/components/automations/automation-usage-model.tssrc/renderer/src/components/automations/external-automation-unchecked-hosts.tssrc/renderer/src/components/browser-extension-permission-messages.tssrc/renderer/src/components/dashboard-popout/AgentKanbanCard.tsxsrc/renderer/src/components/dashboard/DashboardAgentChildDisclosure.tsxsrc/renderer/src/components/dashboard/DashboardAgentRow.tsxsrc/renderer/src/components/editor/CheckRunJobs.tsxsrc/renderer/src/components/editor/ConflictComponents.tsxsrc/renderer/src/components/editor/IpynbViewer.tsxsrc/renderer/src/components/editor/closed-unsaved-files-toast.tssrc/renderer/src/components/editor/combined-diff/review-controls/combined-diff-notes-popover.tsxsrc/renderer/src/components/editor/combined-diff/review-controls/combined-diff-toolbar.tsxsrc/renderer/src/components/editor/csv/CsvViewer.tsxsrc/renderer/src/components/github-item-dialog/inspect-pull-request/pr-files-combined-diff-toolbar.tsxsrc/renderer/src/components/github-project/project-view-error-copy.tssrc/renderer/src/components/github/CommentReactions.tsxsrc/renderer/src/components/github/PRFilterSections.tsxsrc/renderer/src/components/gitlab-item-dialog/gitlab-description-tab.tsxsrc/renderer/src/components/host-picker/host-picker-copy.tssrc/renderer/src/components/linear-project-overview-content.tsxsrc/renderer/src/components/linear-project-view-surfaces.tsxsrc/renderer/src/components/linear-scope-selector.tsxsrc/renderer/src/components/native-chat-restart-action-notifications.tssrc/renderer/src/components/native-chat-resume-activity-label.tssrc/renderer/src/components/native-chat/NativeChatAwaitingInputRow.tsxsrc/renderer/src/components/native-chat/NativeChatTaskList.tsxsrc/renderer/src/components/native-chat/NativeChatToolRun.tsxsrc/renderer/src/components/native-chat/NativeChatTranscriptChrome.tsxsrc/renderer/src/components/native-chat/NativeChatTurnDiffRollup.tsxsrc/renderer/src/components/native-chat/background-task-words-text.tssrc/renderer/src/components/native-chat/native-chat-image-label.tssrc/renderer/src/components/native-chat/native-chat-subagent-group-words-text.tssrc/renderer/src/components/native-chat/native-chat-tool-run-label.tssrc/renderer/src/components/onboarding/AgentStep.tsxsrc/renderer/src/components/pr-check-counts.tssrc/renderer/src/components/project-host-count-label.tssrc/renderer/src/components/pull-request-page/files/toolbar.tsxsrc/renderer/src/components/repo/NestedRepoScanLimitNotice.tsxsrc/renderer/src/components/right-sidebar/AiVaultScanIssueBanners.tsxsrc/renderer/src/components/right-sidebar/AiVaultScanProgressStrip.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionListBar.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionUnsavedNotice.tsxsrc/renderer/src/components/right-sidebar/FolderWorkspacePrChecksPanel.tsxsrc/renderer/src/components/right-sidebar/FolderWorkspaceWorktreesPanel.tsxsrc/renderer/src/components/right-sidebar/SearchResultsPane.tsxsrc/renderer/src/components/right-sidebar/checks-panel/checks-list.tsxsrc/renderer/src/components/right-sidebar/checks-panel/comments-list.tsxsrc/renderer/src/components/right-sidebar/checks-panel/conflict-summary.tsxsrc/renderer/src/components/right-sidebar/checks-panel/triage-strip.tsxsrc/renderer/src/components/right-sidebar/file-explorer-multi-drag-image.tssrc/renderer/src/components/right-sidebar/github-pr-stack-confirmation.tssrc/renderer/src/components/right-sidebar/github-pr-stack-merge.tssrc/renderer/src/components/right-sidebar/source-control-count-localized-copy.tssrc/renderer/src/components/right-sidebar/source-control/commit/bulk-action-bar.tsxsrc/renderer/src/components/right-sidebar/source-control/commit/discard-confirmation.tssrc/renderer/src/components/right-sidebar/source-control/commit/discard-dialog.tsxsrc/renderer/src/components/right-sidebar/source-control/commit/use-discard-confirmation.tssrc/renderer/src/components/right-sidebar/source-control/listing/branch-section.tsxsrc/renderer/src/components/right-sidebar/source-control/listing/review-note-count-title.tssrc/renderer/src/components/right-sidebar/source-control/listing/section-header.tsxsrc/renderer/src/components/right-sidebar/source-control/notes/diff-comments-clear-dialog-state.tssrc/renderer/src/components/right-sidebar/source-control/panel/branch-context-stats.tssrc/renderer/src/components/right-sidebar/source-control/sync/compare-summary.tsxsrc/renderer/src/components/right-sidebar/useFileExplorerImport.tssrc/renderer/src/components/settings/ComputerUsePane.tsxsrc/renderer/src/components/settings/McpConfigFileRow.tsxsrc/renderer/src/components/settings/OrchestrationSkillAgentCoverage.tsxsrc/renderer/src/components/settings/WarpThemeImportModal.tsxsrc/renderer/src/components/settings/agent-permission-override-notice.tsxsrc/renderer/src/components/settings/mcp-config-summary.tssrc/renderer/src/components/settings/useWarpThemeImport.tssrc/renderer/src/components/sidebar/AddRepoNestedImportStep.tsxsrc/renderer/src/components/sidebar/DeleteWorktreeDirtyChangeHint.tsxsrc/renderer/src/components/sidebar/DeleteWorktreeLineageNotice.tsxsrc/renderer/src/components/sidebar/HiddenWorktreeRecoveryList.tsxsrc/renderer/src/components/sidebar/HostRemoveDialog.tsxsrc/renderer/src/components/sidebar/ImportedWorktreesVisibilityLine.tsxsrc/renderer/src/components/sidebar/LocalGitToolchainScanBanner.tsxsrc/renderer/src/components/sidebar/NewExternalWorktreesInboxLine.tsxsrc/renderer/src/components/sidebar/PreservedBranchBatchReviewDialog.tsxsrc/renderer/src/components/sidebar/ProjectGroupDeleteDialog.tsxsrc/renderer/src/components/sidebar/SetupScriptPromptCard.tsxsrc/renderer/src/components/sidebar/SeveredTerminalDaemonBanner.tsxsrc/renderer/src/components/sidebar/WorkspaceKanbanDrawerHeader.tsxsrc/renderer/src/components/sidebar/WorkspaceKanbanSearchField.tsxsrc/renderer/src/components/sidebar/WorktreeCardMetaBadges.tsxsrc/renderer/src/components/sidebar/WorktreeCardPorts.tsxsrc/renderer/src/components/sidebar/WorktreeLinkedItemsField.tsxsrc/renderer/src/components/sidebar/active-filter-count-label.tssrc/renderer/src/components/sidebar/add-remote-host-ssh-actions.tssrc/renderer/src/components/sidebar/delete-worktree-dialog-copy.tssrc/renderer/src/components/sidebar/local-base-ref-suggestion-toast.tsxsrc/renderer/src/components/sidebar/preserved-branch-batch-toast.tsxsrc/renderer/src/components/sidebar/removal-unsaved-files.tssrc/renderer/src/components/sidebar/use-worktree-card-workspace-actions.tssrc/renderer/src/components/sidebar/workspace-batch-action-labels.tssrc/renderer/src/components/sidebar/worktree-card-model.tssrc/renderer/src/components/sidebar/worktree-list/rows/HostSectionHeader.tsxsrc/renderer/src/components/sidebar/worktree-list/rows/use-project-group-dialogs.tssrc/renderer/src/components/skills/SkillBundleInstallOutcome.tsxsrc/renderer/src/components/skills/SkillInstallAgentPicker.tsxsrc/renderer/src/components/skills/SkillInstallReviewContent.tsxsrc/renderer/src/components/skills/SkillInstallRiskNotice.tsxsrc/renderer/src/components/skills/skill-delete-copy.tssrc/renderer/src/components/skills/skill-display-labels.tssrc/renderer/src/components/skills/skill-freshness-summary-headline.tsxsrc/renderer/src/components/skills/skill-managed-removal-summary.tssrc/renderer/src/components/skills/skill-plan-op-copy.tssrc/renderer/src/components/skills/skill-share-preview-summary.tssrc/renderer/src/components/skills/use-skill-delete-flow.tssrc/renderer/src/components/stats/UsageBreakdownSection.tsxsrc/renderer/src/components/stats/UsageOverviewPane.tsxsrc/renderer/src/components/stats/usage-overview-sections.tsxsrc/renderer/src/components/status-bar/CodexSwitcherMenu.tsxsrc/renderer/src/components/status-bar/NativeChatResumeStatusSegment.tsxsrc/renderer/src/components/status-bar/PortsStatusSegment.tsxsrc/renderer/src/components/status-bar/RemoteServerUpdateStatusSegment.tsxsrc/renderer/src/components/status-bar/SkillUpdateStatusSegment.tsxsrc/renderer/src/components/status-bar/StatusBarAccountControls.tsxsrc/renderer/src/components/status-bar/WorkspaceSpaceCompactPanel.tsxsrc/renderer/src/components/status-bar/resource-manager-terminal-copy.tssrc/renderer/src/components/status-bar/resource-usage-popover-body.tsxsrc/renderer/src/components/status-bar/resource-usage-popover-summary.tsxsrc/renderer/src/components/status-bar/ssh-status-segment-copy.tssrc/renderer/src/components/status-bar/tooltip.tsxsrc/renderer/src/components/status-bar/use-workspace-space-manager-panel.tssrc/renderer/src/components/status-bar/workspace-space-breakdown-list.tsxsrc/renderer/src/components/status-bar/workspace-space-decision-hover-card.tsxsrc/renderer/src/components/status-bar/workspace-space-decision-labels.tssrc/renderer/src/components/status-bar/workspace-space-format.tssrc/renderer/src/components/status-bar/workspace-space-manager-toolbar.tsxsrc/renderer/src/components/task-page/github/List.tsxsrc/renderer/src/components/task-page/jira/Content.tsxsrc/renderer/src/components/task-page/linear/IssueToolbar.tsxsrc/renderer/src/components/task-page/linear/linear-attribute-count-labels.tssrc/renderer/src/components/task-page/task-page-pr-delta-summary.tssrc/renderer/src/components/task-source-host-status-labels.tssrc/renderer/src/components/terminal-pane/NewerDaemonHoldBanner.tsxsrc/renderer/src/components/terminal-pane/newer-daemon-hold-state.tssrc/renderer/src/components/terminal-pane/terminal-drop-upload-report.tssrc/renderer/src/components/terminal-pane/terminal-native-file-drop.tssrc/renderer/src/components/workspace-cleanup/workspace-cleanup-confirm-remove.tsxsrc/renderer/src/components/workspace-cleanup/workspace-cleanup-scan-notice.tssrc/renderer/src/components/workspace-cleanup/workspace-cleanup-selection-model.tssrc/renderer/src/components/workspace-cleanup/workspace-cleanup-sort-header.tsxsrc/renderer/src/components/worktree-jump-palette-surface.tsxsrc/renderer/src/hooks/composer-drop-failure-toast.tssrc/renderer/src/i18n/lazy-locale.test.tssrc/renderer/src/i18n/locales/de.jsonsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/pt.jsonsrc/renderer/src/i18n/locales/ru.jsonsrc/renderer/src/i18n/locales/tr.jsonsrc/renderer/src/i18n/locales/zh-Hant.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/native-file-drop-rejection-message.tssrc/renderer/src/ssh/ssh-host-moved-automations-copy.tssrc/renderer/src/ssh/ssh-host-server-status-copy.tssrc/shared/orca-i18n-instance.ts
Files with no reviewable changes: 1-
- config/i18next.config.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
-
| const property = (name) => options.properties.find((entry) => entry.name?.getText() === name) | ||
| const one = property('defaultValue_one') |
There was a problem hiding this comment.
Recognize quoted plural option names.
If a call uses { count, 'defaultValue_one': 'One file' }, getText() returns the quoted property name. pluralFamilyDefaults then records only the base key. Catalog sync can add that base key instead of the _one and _other keys that the counted runtime lookup uses. Compare the property name’s AST text value rather than its source spelling. (raw.githubusercontent.com)
Proposed fix
-
--- "a/config/scripts/locale-plural-forms.mjs" +++ "b/config/scripts/locale-plural-forms.mjs" @@ -20,7 +20,13 @@ if (PLURAL_KEY_RE.test(key) || !options || !ts.isObjectLiteralExpression(options)) { return undefined } - const property = (name) => options.properties.find((entry) => entry.name?.getText() === name) + const property = (name) => + options.properties.find( + (entry) => + entry.name && + (ts.isIdentifier(entry.name) || ts.isStringLiteral(entry.name)) && + entry.name.text === name + ) const one = property('defaultValue_one') // Without defaultValue_one, count only fills {{count}} in a singular key; without count, i18next reads the base key. if (!one || !property('count')) {
Committable suggestion
-
IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.Suggested changeconst property = (name) => options.properties.find((entry) => entry.name?.getText() === name) const one = property('defaultValue_one') const property = (name) => options.properties.find( (entry) => entry.name && (ts.isIdentifier(entry.name) || ts.isStringLiteral(entry.name)) && entry.name.text === name ) const one = property('defaultValue_one')
# Conflicts: # src/renderer/src/i18n/lazy-locale.test.ts
Item 4 of the i18n audit follow-ups, part 1 of 2: the mechanism plus nearly every call site.
Problem
Plural call sites branched in code and passed literal suffixed keys:
resolvePluralFamilyKeythen stripped the suffix again so CLDR could pick the form. Extraction ran withdisablePlurals: true, so the English_onedefault was never checked for drift.Change
Native plural calls. Sites now use i18next's native form:
An AST codemod converted the
count === 1ternaries (about 310 families, in 166 source files). It only rewrote a ternary when the condition tested the same value passed ascount, and the two branches had the same options. A handful of irregular sites were converted by hand, and leftover locals the codemod made unused were removed. Catalog keys are unchanged (x_one/x_other).defaultValue_oneadded where it was missing. 21 families already called the base key but had nodefaultValue_one, so their_onecopy existed only in en.json. They now pass it explicitly, which lets the drift gate track it.English fallbacks use English plural rules. i18next picks
defaultValue_<suffix>with the active language's rule. So a Russian user with a key missing from their catalog would see English singular copy for 21 ("21 file"). The sharedtranslatenow passes the English default chosen by English rules. A pass-throughcount: undefinedis treated like an absent count.Extraction is plural-aware.
disablePluralsis removed:countwithoutdefaultValue_onestill means a singular key that only fills{{count}}, and stays singular in en.json.count, is still reported, so the old pattern can't creep back.Catalog verify and sync understand native plural calls.
verify:localization-catalogandsync:localization-catalogexpand a native plural call (countplusdefaultValue_one) into itsx_one/x_otherEnglish entries.Dead base keys removed. 22 base keys duplicated a sibling plural family in every catalog. i18next never reads them once
countis passed, so they were removed.Kept for the follow-up
Twelve families, about 13 call sites, keep special exact-1 copy ("Used the browser" vs "Used the browser {{count}} times"). Those families have no English
_one. The follow-up PR converts them andResourcePtyPanel, then dropsresolvePluralFamilyKeyfrom desktop translate. Mobile still uses it.Verified
verify:localization-*checks pass, along with sync andpnpm tc.