Skip to content

refactor(i18n): check that each key sits in its feature's part - #1685

Merged
devswha merged 1 commit into
mainfrom
refactor/i18n-cleanup
Oct 22, 2026
Merged

devswha merged 1 commit into
mainfrom
refactor/i18n-cleanup

Conversation

@devswha

@devswha devswha commented Oct 22, 2026

Copy link
Copy Markdown
Owner

The last PR of the i18n split (split plan, section 4 and the deferred items of section 2.4). The split PRs (#1673, #1674, #1676, #1677, #1679, #1680, #1681, #1683) moved every feature-only key into src/lib/i18n/<feature>.{ko,ja,zh}.ts and were move-only. This PR carries the non-move changes the split left for the end. It is not move-only: it changes a test, a test message and CONTRIBUTING.md, so it takes the normal review path.

Changes

  • Placement check (src/lib/i18n.test.ts). A new test in "dictionary parts" fails when:

    • a part keeps a key that a file outside the part also uses, reported as Cancel (in palette, belongs in base);
    • the base keeps a key that only one part's files use, reported as Enable notifications (in base, belongs in palette);
    • KO_PARTS has a part that PART_FILES does not list.

    PART_FILES lists each part's files, the same lists as the part headers. A key's uses are the files that call t()/tt() with it plus, for the 13 label maps, the map's own file. To support this, labelMapKeys() becomes labelMapUses() and returns [key, file] pairs; the existing missing/unused test takes just the keys, so it checks the same set as before. File paths are normalized to / so the check also holds on Windows. Only KO_PARTS is checked, because the existing "same part in every language" test already ties JA and ZH to it.

  • Emptied section comments. // ---- key bar ----, // ---- markdown ----, // ---- install help ---- and // ---- sign-in ---- no longer have any entries in the base files (ko, ja, zh) and are removed.

  • src/conventions.test.ts. The "New workspace" failure message now points to src/lib/i18n.*.ts or src/lib/i18n/*.ts.

  • CONTRIBUTING.md. The UI text rule now says bun run test:unit also fails on an entry kept in the wrong file.

Checks

  • HERDR_TEST_MODE=unit bun test src/lib/i18n.test.ts src/conventions.test.ts: 28 pass, 0 fail.
  • The placement test was checked by breaking it on purpose, in all three languages, then restoring the files:
    • moving the shared key "Cancel" from the base into the palette part fails with Cancel (in palette, belongs in base);
    • moving a palette-only key into the base fails with Enable notifications (in base, belongs in palette).
  • The composed KO, JA and ZH are identical to main's (sorted-JSON dump diff empty, EQUIVALENT): only comment lines leave the dictionaries.
  • bun run typecheck: passes.
  • bun run check fast: passes (unit 6128 pass, 0 fail, 12 skip in 434 files, 8 at a time, 58.2s).

No changelog fragment: users see no change.

The i18n split moved every feature-only key into src/lib/i18n/<feature>.*.ts.
i18n.test.ts now holds each part's files (PART_FILES) and fails when a part
keeps a key another file also uses, or the base keeps a key only one part's
files use; label-map keys count as used in their map's file. The four section
comments the split left without entries go, and the conventions message and
CONTRIBUTING.md name the part files.
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 68bb11f and 5939d5b.

📒 Files selected for processing: 6
  • CONTRIBUTING.md
  • src/conventions.test.ts
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • src/lib/i18n.test.ts
  • src/lib/i18n.zh.ts

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.

@devswha

devswha commented Oct 22, 2026

Copy link
Copy Markdown
Owner Author

CodeRabbit did not review this PR (review limit reached). It changes no workflow, contract or auth code, so it merges on its required checks and this merge-pass review, per AGENTS.md.

Merge-pass review (not move-only, so reviewed in full).

The diff does what the body says.

  • Placement test. Each key gets every file that uses it: its t()/tt() call sites plus the file of each label map that holds it. A key belongs to the part whose PART_FILES contain all of those files, and otherwise to the base. Every key of every part, the base included, must sit where it belongs.
  • Other changes.
    • The emptied section comments are removed.
    • The conventions message names src/lib/i18n/*.ts too.
    • CONTRIBUTING.md gets its one-line update.

Re-run on the PR head 5939d5b in a separate checkout:

  • Equivalence: the composed KO/JA/ZH dumped as sorted JSON are byte-identical to the merge base (EQUIVALENT); only comment lines leave the dictionaries.
  • Tests: HERDR_TEST_MODE=unit bun test src/lib/i18n.test.ts src/conventions.test.ts gives 28 pass, 0 fail.
  • Shared key moved into a part: "Cancel" moved into the palette part in all three languages fails with Cancel (in palette, belongs in base).
  • Part key moved into the base: a palette-only key ("Enable notifications") moved into the base in all three languages fails with Enable notifications (in base, belongs in palette).

Notes, not blocking:

  • PART_FILES repeats the file lists in the part headers, so the two change together.
  • A new component that is in no PART_FILES list puts its strings in the base. That is correct but quiet; assign the file when the feature grows.

@devswha
devswha merged commit 4f156f2 into main Oct 22, 2026
9 checks passed
@devswha
devswha deleted the refactor/i18n-cleanup branch October 22, 2026 21:27
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