Skip to content

refactor(i18n): add locale dictionary parity tests - #50835

Open
imyu37 wants to merge 2 commits into
anomalyco:devfrom
imyu37:test/i18n-parity
Open

imyu37 wants to merge 2 commits into
anomalyco:devfrom
imyu37:test/i18n-parity

Conversation

@imyu37

@imyu37 imyu37 commented Sep 23, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #50772

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

V2 has no guard against locale dictionary drift: a bad placeholder, a stray key, or a dropped translation lands silently (English fallback hides it). This adds two test files:

  • packages/app/src/runtime/i18n/parity.test.ts
  • packages/ui/src/i18n/parity.test.ts

Each asserts that translated dicts stay aligned with en: identical {{param}} sets per key, no unknown keys, zh/zht key parity with each other, and a "missing keys must not grow" baseline (app 418, ui 51 as of today — the constant has a comment saying it should only ever go down). Deliberately not a strict 100% parity assert, since partial locales with English fallback are the intended V2 design.

How did you verify your code works?

  • cd packages/app && bun run test:unit → 906 pass, 0 fail (new file included in the run)
  • cd packages/ui && bun test src → 120 pass, 0 fail
  • Typecheck clean for both new files
  • Mutation-tested the assertions outside the repo: wrong placeholder / deleted key / unknown key each fail with precise messages, so the checks aren't no-ops

Screenshots / recordings

Not a UI change — no screenshots needed.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@imyu37 imyu37 changed the title test(i18n): add locale dictionary parity tests refactor(i18n): add locale dictionary parity tests Sep 23, 2026
@dat-rd

dat-rd commented Oct 18, 2026

Copy link
Copy Markdown

I opened a version of this earlier and the bot closed it as a duplicate of this PR, which was the right call. Two of the three changes I had made are worth having here, and I would rather not open a competing PR for them.

The missing-key baseline will not survive contact with the codebase. Item 3 in the issue asks for a count that never rises above a constant (app 418, ui 51). English gains keys with every feature PR, so a fixed number fails on the next English string added, and it also fails on the two translation PRs currently open (#51708, #53174) whenever a locale gains a key before English does. A ratio survives that: each locale keeps at least 80% of the English key count. The least complete locale on dev is at 84.6%, so there is room for English to grow before the floor bites.

Checking every locale is barely more work than checking two. The loop over locales already exists for the baseline; running placeholder and subset checks across all 62 app locales and 61 ui locales instead of only zh and zht costs the same traversal. Today both packages report zero placeholder mismatches, so a wider check passes rather than finding work.

Item 4 does hold right now. zh and zht carry identical key sets in both packages, 858 keys each in the app package and 248 in ui, so the assertion can be added as written.

One blocker is separate and needs a small PR before the subset assertion can pass: 19 app locale dictionaries still define four key families English dropped, session.question.pending, session.background.runningCount, session.background.shell and session.background.subagent, which is 116 unreachable entries. I filed #56610 and opened #56611 to remove them. Comparing keys by plural family rather than exactly is also needed, otherwise the legitimate .few / .many variants read as unknown.

Happy to test or rebase anything here if that is easier than rewriting it.

This branch has not been deployed

No deployments
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.

[FEATURE]: Add i18n dictionary parity regression tests for app/ui locales

2 participants