Skip to content

Decouple feature copy from locale parity - #8512

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/i18n-catalog-decoupling
Jul 30, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/i18n-catalog-decoupling

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

This replaces #8501 with the small, independently useful part of the localization change. Feature copy can now land without fabricating target-language entries, while the permanent bilingual translation source remains a separate follow-up.

ELI5: what are we doing?

Imagine Orca has five phrasebooks: English, Spanish, Japanese, Korean, and Chinese.

Today, whenever someone adds a sentence to the English phrasebook, our tools require adding something to all four translated phrasebooks immediately. If nobody has translated it yet, those books often receive copied English. That makes them look complete even though they are not.

The plan is:

  1. PR A — stop pretending: This PR allows a translated phrasebook to leave a sentence missing. Orca then shows the real English sentence as a safe fallback. It also adds a scanner that catches broken or undeclared messages without creating hundreds of thousands of bookkeeping lines.
  2. PR B — build the proper translation binder: Add one standard format that keeps a message's stable ID, English source, translation, and review status together. A deterministic compiler turns that binder into the same runtime files Orca already understands.
  3. PR C — move the translations carefully: Copy every existing translation into the new binder without retranslating it. Preserve known corrections, remove fake copied-English filler, and prove every changed value has an explanation.
  4. PR D — remove the temporary shelves: Make the new binder the only translation source, generate runtime bundles during the build, and delete the old repair scripts and migration bookkeeping.

Afterward, the everyday workflow is simple:

  • A feature developer adds the English message only.
  • Orca shows an existing current translation when one is available.
  • If a translation is missing or stale, Orca safely shows current English.
  • A separate translation PR can add or review the target-language value later.
  • Everything needed to display translations remains bundled offline with the app.

The previous large PR tried to create a custom index card for every existing sentence in every language before introducing the permanent binder. This split avoids making that temporary index-card system part of Orca's architecture.

What changed

  • Target catalogs may omit English keys; existing i18next runtime fallback remains authoritative for missing values.
  • sync:localization-catalog adds English declarations only and never edits target catalogs.
  • Existing target values still fail on incompatible placeholders and are never overwritten automatically.
  • Maintained i18next-cli extraction runs once in normal PR CI using isolated temporary output rather than a committed second English catalog.
  • Extraction fails for statically extracted keys missing from en.json and incompatible inline placeholders; legacy orphans, dynamic defaults, and wording-only drift are reported without a permanent disposition database.
  • Six previously dynamic or missing declarations were made statically extractable, producing eight intentionally sparse English entries across the four target catalogs.
  • Whole-catalog machine-translation bootstrap and repair commands were removed from normal package scripts and guarded by a contract test.
  • Localization ownership and renderer/main fallback tests were added.

Explicitly deferred

This PR does not add per-locale state sidecars, Git-history-derived product semantics, a reviewed-correction ledger, committed extraction output, orphan dispositions, a broad main-process literal allowlist, generated key types, or a three-OS extraction matrix.

Reviewed/stale workflow state and cleanup of the existing extraction baseline belong in the permanent bilingual source migration. Until then, coverage and legacy extraction drift are honestly reported rather than represented as fully classified.

Whole localization plan

Design principles

  • Product source owns stable message IDs and current English defaults.
  • Feature PRs change English only; they never fabricate or overwrite target-language values.
  • Translation PRs own target values, review state, and source confirmation.
  • Runtime bundles remain offline, lazy-loaded, and compatible with the current i18next call sites.
  • A standard bilingual representation owns source/target workflow state. Git history, generated catalogs, and migration audits do not become parallel product databases.
  • Generated outputs are deterministic and disposable. Reviewers inspect canonical translation inputs, not compiled runtime JSON.

PR A — decouple feature copy (this PR)

Land the smallest safe behavior change:

  1. Permit sparse target catalogs and rely on the existing English fallback.
  2. Make catalog sync write English only.
  3. Preserve all existing target values byte-for-byte and fail incompatible placeholders.
  4. Add maintained extraction with temporary output and one normal CI pass.
  5. Report the legacy baseline without committing 1,877+ orphan dispositions or other exception databases.
  6. Remove whole-catalog translation/repair commands from normal package workflows.
  7. Add ownership and explicit renderer/main fallback tests.

Temporary limitations accepted after PR A:

  • Reviewed versus machine translation is not rigorously represented.
  • Stale translations are not automatically suppressed yet.
  • The current report contains 1,887 unreferenced English entries, 38 wording-only inline-default differences, and 25 dynamic defaults.
  • Main-process localization coverage remains at its existing boundary; this PR does not add a 500-record literal allowlist.

These are visible migration metrics, not claims of completeness. They must not grow into new state categories or permanent historical policy.

PR B — define the permanent source and compiler

Default format choice: XLIFF 2, unless implementation work identifies a documented blocker before this PR begins.

Add a narrow translation-source contract:

  1. One canonical English source file contains stable unit IDs, current English text, and translator notes/context.
  2. Each target locale has a sparse bilingual file. A translated unit contains its stable ID, the English source snapshot it was confirmed against, its target value, and standard workflow state.
  3. Missing target units mean untranslated. A differing current English source versus the target unit's source snapshot means stale.
  4. A deterministic compiler joins the English source with each sparse target file and emits the existing i18next bundle shape into build staging, not as another hand-edited source.
  5. The compiler rejects duplicate IDs, malformed units, empty target values, incompatible placeholders, unsupported states, and nondeterministic ordering.
  6. Renderer, web, and Electron main-process loaders continue consuming the same logical bundles and fallback behavior.

PR B must include golden compiler tests, source/target schema tests, placeholder tests, stale/missing fallback tests, and packaged-build integration. It must not import the full locale inventory yet; that keeps the format/compiler review separate from the data migration.

PR C — migrate existing translations once

Perform a byte-preserving migration into the permanent source:

  1. Export every current stable English ID and value into the English XLIFF source.
  2. Import every non-placeholder target value into its sparse target file without retranslation.
  3. Treat unproven target values as imported/unreviewed rather than claiming human review.
  4. Use the preserved historical correction audit once to seed only known reviewed values. Keep the audit as migration evidence, not permanent runtime or verification input.
  5. Remove byte-equal English parity filler unless explicitly classified as intentional English.
  6. Import terminology as glossary data and known forbidden mistranslations as QA rules rather than repair scripts.
  7. Compare compiled runtime bundles with the current catalogs and require an explained result for every difference.

Migration acceptance criteria:

  • Every current target value is either byte-preserved, explicitly retired, or documented as parity filler.
  • Known reviewed corrections remain byte-preserved and reviewed.
  • Missing and stale units resolve to current English.
  • Placeholders and plural/count behavior remain valid.
  • The build is reproducible from pinned repository inputs without network access.
  • Runtime bundle loading and language selection remain unchanged across local, SSH, WSL, and packaged execution boundaries.

PR D — switch ownership and delete the bridge

After migrated bundles are proven equivalent:

  1. Make XLIFF the only editable translation source.
  2. Point build/dev/test/package flows at the deterministic compiler output.
  3. Remove committed target JSON as canonical inputs; generated runtime bundles remain build artifacts.
  4. Delete legacy bootstrap, repair, history-classification, override, and migration-audit machinery that no longer owns behavior.
  5. Replace the current extraction-debt report with direct source/XLIFF consistency checks.
  6. Keep one required extraction/compile job in ordinary PR CI. Run cross-platform determinism through focused path/line-ending tests and scheduled or tooling-change validation rather than a three-OS install matrix on every feature PR.
  7. Keep localization ownership on canonical source files and require localization-only PRs for target updates.

PR D is complete only when there is one canonical English representation, one canonical target representation per locale, no permanent Git-history interpretation, no correction-value duplication, and no large literal/disposition database.

Ownership, sequencing, and rollback

  • Localization owner: @brennanbenson until a broader localization owner/team is assigned.
  • Sequence: PR A merges first; PR B targets PR A's merged result; PR C targets the proven compiler; PR D switches ownership only after bundle equivalence passes.
  • Each PR remains independently reviewable and reversible. No follow-up should depend on merging the preserved full-implementation branch.
  • The exact former Decouple feature copy from translated locale catalogs #8501 tree is retained on brennanb2025/i18n-architecture-improvements-full for migration evidence only and is not a merge candidate.
  • The permanent migration should be scheduled within one or two release cycles. If it is not funded in that window, the team should explicitly revisit whether PR A's temporary reporting limitations remain acceptable.
  • No PR in this sequence introduces a runtime translation network dependency or merges automatically.

Size

  • 19 files
  • 894 additions, including 561 lockfile lines for the pinned extractor
  • 135 deletions

Validation

  • pnpm run typecheck
  • pnpm run lint
  • 40 focused and affected tests
  • Catalog validation: 10,581 English entries, 8 intentionally missing per target locale
  • Maintained extraction: 8,694 keys, no missing static English declarations or incompatible static placeholders
  • git diff --check

The worktree is clean and the branch is based on current main. This PR should remain unmerged until live checks complete.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@brennanb2025, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 11 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f48baa9-85c9-4ec8-8bce-a8472c4b652d

📥 Commits

Reviewing files that changed from the base of the PR and between c1ee448 and 162f791.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • .github/CODEOWNERS
  • .github/workflows/pr.yml
  • config/scripts/verify-localization-extraction.mjs
  • config/scripts/verify-localization-extraction.test.mjs
  • package.json
📝 Walkthrough

Walkthrough

The PR adds i18next extraction configuration and verification, integrates extraction checks into package scripts and the PR workflow, and adds tests for extraction diagnostics. Locale catalog verification now reports parity issues without repairing target catalogs, while documentation and package contract tests reflect the revised process. Runtime localization tests cover caller-provided fallbacks for missing entries, and several UI translation keys, interpolation calls, placeholders, labels, and English catalog entries are updated.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed, but it does not follow the required template sections like Screenshots, AI Review Report, Security Audit, and Notes. Add the missing template sections with explicit screenshots/no visual change, AI review summary, security audit, and notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and directly matches the main change: separating feature copy updates from locale parity.
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.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
src/renderer/src/components/native-chat/NativeChatToolRun.tsx (1)

110-115: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Manual singular/plural split instead of i18next plural forms.

Using two hardcoded keys (countOne/countN) instead of i18next's count-based plural suffixes works for English but can't represent plural rules for locales with more than two forms (e.g. Russian, Arabic, Polish). Since this repo already lazy-loads non-English catalogs via i18next, consider switching to t('components.native-chat.tool.count', { count: callCount }) with count_one/count_other keys for future-proofing.

src/renderer/src/components/stats/UsageBreakdownSection.tsx (1)

51-53: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Concatenating separately-translated fragments locks word order across locales.

{row.sessions} {translate('sessions •')} {row.eventsOrTurns} {eventsOrTurnsLabel} stitches three independently translated pieces together in a fixed English order. Non-English locales can't reorder count/unit/label without changing the concatenation logic in code, since each fragment is translated (and interpolated) separately. Consider a single template string with {{value0}}/{{value1}} placeholders instead so translators can control ordering.

♻️ Proposed single-template approach
-            <div className="text-xs text-muted-foreground">
-              {row.sessions}{' '}
-              {translate('auto.components.stats.UsageBreakdownSection.02a046792e', 'sessions •')}{' '}
-              {row.eventsOrTurns} {eventsOrTurnsLabel}
+            <div className="text-xs text-muted-foreground">
+              {translate(
+                'auto.components.stats.UsageBreakdownSection.sessionsSummary',
+                '{{value0}} sessions • {{value1}} {{value2}}',
+                { value0: row.sessions, value1: row.eventsOrTurns, value2: eventsOrTurnsLabel }
+              )}
config/scripts/verify-localization-extraction.mjs (1)

83-96: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add a timeout to execFileAsync. The extraction step can hang indefinitely if i18next-cli stalls; the --sync-primary run already targets the configured temp output path, so it won’t touch the committed src/renderer/src/i18n/locales/en.json.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fef184ce-460f-4263-80d0-42d2541d9702

📥 Commits

Reviewing files that changed from the base of the PR and between 0b65d72 and 6c1364c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (18)
  • .github/CODEOWNERS
  • .github/workflows/pr.yml
  • config/localization-audit.md
  • config/scripts/localization-package-contract.test.mjs
  • config/scripts/verify-localization-catalog.mjs
  • config/scripts/verify-localization-catalog.test.mjs
  • config/scripts/verify-localization-extraction.mjs
  • config/scripts/verify-localization-extraction.test.mjs
  • i18next.config.ts
  • package.json
  • src/main/i18n/main-i18n-lazy-locale.test.ts
  • src/renderer/src/components/native-chat/NativeChatToolRun.tsx
  • src/renderer/src/components/right-sidebar/use-hosted-review-actions.ts
  • src/renderer/src/components/settings/shortcuts-search.ts
  • src/renderer/src/components/sidebar/AddRepoCloneStep.tsx
  • src/renderer/src/components/stats/UsageBreakdownSection.tsx
  • src/renderer/src/i18n/lazy-locale.test.ts
  • src/renderer/src/i18n/locales/en.json

…alog-decoupling

# Conflicts:
#	.github/workflows/pr.yml
#	package.json
#	pnpm-lock.yaml
Comment on lines 295 to 314
@@ -380,7 +313,7 @@ function verifyLocaleParity(enCatalog, localeName, localeCatalog) {
return 1
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Extra-key failures are now unresolvable by sync:localization-catalog

verifyLocaleCatalog still fails CI when a target catalog contains a key that no longer exists in en.json (extraInLocale). But repairLocaleParity was removed, so sync:localization-catalog --fix no longer removes those orphaned entries. A developer who deletes an English key will now face a CI failure that cannot be fixed with the sync script — they need to either edit target catalogs directly or file a localization PR. Consider adding a note to localization-audit.md explaining that deleting an English key requires a corresponding target-catalog cleanup PR.

Comment on lines +88 to +94
await execFileAsync(process.execPath, [cliPath, 'extract', '--sync-primary', '--quiet'], {
cwd: root,
env: {
...process.env,
ORCA_I18N_EXTRACTION_OUTPUT: outputPattern.split(path.sep).join('/')
}
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 --sync-primary with a redirected output path — verify write destination

The command passes ORCA_I18N_EXTRACTION_OUTPUT pointing at tempDir, and i18next.config.ts uses that env var as the output pattern. However, --sync-primary in some i18next-cli versions writes the primary locale back to a hard-coded path rather than the configured output value. If the CLI writes an updated en.json to src/renderer/src/i18n/locales/en.json instead of tempDir/en.json, the concurrent fs.readFile of en.json in Promise.all races with the write, and the source tree gets modified unexpectedly in CI. A git diff --exit-code step after the extraction job would make the isolation assumption explicit and detectable.

@greptile-apps

greptile-apps Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR decouples feature copy from locale parity by allowing target catalogs to be sparse: missing translations fall through to i18next's existing English fallback rather than failing CI. A new verify:localization-extraction step (using a pinned [email protected]) runs AST extraction into an isolated temp directory and fails only on undeclared keys or incompatible inline placeholders, while orphans and wording drift are reported without blocking.

  • verifyLocaleParity is replaced by verifyLocaleCatalog, which logs missing-translation coverage but fails only on extraInLocale or interpolationMismatches; repairLocaleParity/deleteCatalogEntry are removed so the sync script no longer fabricates or removes target entries.
  • Six previously dynamic or key-selected translate calls in feature components (NativeChatToolRun, UsageBreakdownSection, shortcuts-search, use-hosted-review-actions, AddRepoCloneStep) are refactored into static calls and declared in en.json, producing eight intentionally sparse entries across target catalogs.
  • Whole-catalog bootstrap and repair scripts are removed from package.json and guarded by a new contract test; renderer and main-process fallback behavior is covered by two new tests.

Confidence Score: 5/5

Safe to merge — the catalog verifier correctly narrows its failure conditions, the extraction runs in a fully isolated temp directory, existing target translations are untouched byte-for-byte, and the English fallback path is exercised by two explicit new tests.

All behavioral changes are deliberate and well-tested: the new sparse-catalog contract is covered by updated catalog tests, the extraction comparator is covered by unit tests, and the renderer/main fallback behavior has direct test coverage. The component refactors are mechanically correct and the new en.json entries match the interpolation variables used at the call sites.

Files Needing Attention: No files require special attention. The localization scripts are the most structurally significant change, and they have good test coverage for the key logic paths.

Important Files Changed

Filename Overview
config/scripts/verify-localization-extraction.mjs New extraction verifier: runs i18next-cli to a temp dir, compares extracted keys against en.json, and fails only on undeclared keys or incompatible placeholders; drift and orphans are report-only.
config/scripts/verify-localization-catalog.mjs Replaced verifyLocaleParity (failing on missing keys) with verifyLocaleCatalog (logging missing, failing only on extraInLocale/interpolationMismatches); removed repairLocaleParity and deleteCatalogEntry.
config/scripts/localization-package-contract.test.mjs New contract test guarding that safe scripts remain defined and whole-catalog bootstrap/repair scripts remain absent; reads package.json with a relative path that is CWD-dependent.
i18next.config.ts New i18next-cli config: routes extraction output to ORCA_I18N_EXTRACTION_OUTPUT env var (defaulting to tmp/), restricts locales to en, and configures function names, sorting, and removeUnusedKeys.
src/renderer/src/components/native-chat/NativeChatToolRun.tsx Split single ternary translate() call into two independent calls (countOne / countN), adding countN with {{value0}} interpolation; newly declared in en.json, no target catalog entries exist yet.
src/renderer/src/components/settings/shortcuts-search.ts Renamed key ca6a0c2df7 ("shortcut", no placeholder) to groupShortcut ("{{value0}} shortcut") — fixes a bug where English users saw "shortcut" without the group name; old key becomes an orphan.
.github/CODEOWNERS New CODEOWNERS file assigning localization-related paths (locales/, localization.mjs, locale.mjs, i18next.config.ts) to @brennanb2025.
src/renderer/src/i18n/locales/en.json Adds 8 new English entries (countOne, countN, remoteCloneParentPlaceholder, groupShortcut, closedToast, turns, events, sessions •) that are intentionally absent from all four target catalogs.

Reviews (3): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
config/scripts/verify-localization-catalog.test.mjs (1)

97-124: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the plugin-only diagnostic.

The fixture includes auto.pluginOnly, but the test never verifies that the extra diagnostic reports it. Add an assertion so regressions in plugin-only-key reporting are caught.

Suggested assertions
       expect(report).toHaveBeenCalledWith(expect.stringContaining('0/2 core keys'))
+      expect(report).toHaveBeenCalledWith(expect.stringContaining('extra'))
+      expect(report).toHaveBeenCalledWith(expect.stringContaining('auto.pluginOnly'))
       expect(report).toHaveBeenCalledWith(expect.stringContaining('interpolation mismatch'))

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 349bcccf-1535-47cd-b10e-8ae2450f6260

📥 Commits

Reviewing files that changed from the base of the PR and between 6c1364c and c1ee448.

📒 Files selected for processing (3)
  • .github/workflows/pr.yml
  • config/scripts/verify-localization-catalog.mjs
  • config/scripts/verify-localization-catalog.test.mjs

@brennanb2025
brennanb2025 merged commit 5e00a30 into main Jul 30, 2026
46 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* Decouple feature copy from locale parity

* Fix undeclared dynamic localization key check

* Fix localization code owner
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.

1 participant