Skip to content

refactor(i18n): move devices and usage-only strings into src/lib/i18n/ - #1681

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

devswha merged 1 commit into
mainfrom
refactor/i18n-devices-usage

Conversation

@devswha

@devswha devswha commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Next PR of the i18n split (split plan, section 4). The strings that only the devices and usage files use (each feature into its own part) move out of the three base dictionaries into src/lib/i18n/devices.{ko,ja,zh}.ts and src/lib/i18n/usage.{ko,ja,zh}.ts. t(), the English keys, every translation, placeholders, the English fallback and all call sites stay the same.

What changes

  • devices: 93 keys in each language, byte for byte, in the order each language's file had them. A key moves only when every file that uses it is one of: components/DevicesPanel.tsx (with VIA), components/PhonePanel.tsx, components/PortalPanel.tsx, components/PushTestControls.tsx, components/AccessGate.tsx, components/LanExposureNotice.tsx, lib/install.ts.
  • usage: 77 keys in each language, byte for byte, in the order each language's file had them. A key moves only when every file that uses it is one of: components/UsageSettings.tsx, components/UsageAccountDialog.tsx, components/UsageLocalLogin.tsx, components/UsageHubConnect.tsx, components/CLIProxyLogin.tsx, components/UsageMeters.tsx, lib/usage.ts (with WINDOW_LABEL).
  • Composition: each base file gains 2 imports and 2 KO_PARTS / JA_PARTS / ZH_PARTS entries. Nothing else in the base files changes; no test or docs change.

Key list

Regenerated with the split plan's ownership script on this branch's base, b6085f11 (keys collected as i18n.test.ts does: t()/tt() literals plus the 13 label maps, per file):

  • devices: 93 keys, identical to the plan's list from 8b5aaba.
  • usage: 77 keys, identical to the plan's list from 8b5aaba.

Checks

  • Same dictionaries: the composed KO, JA and ZH (every key and value) dumped as sorted JSON on b6085f11 and on this branch are byte-identical (EQUIVALENT).
  • --color-moved summary: git diff --color-moved=plain origin/main...HEAD over the base and part files: 1050 lines shown as moved. The non-moved lines are 66 added lines: imports, parts entries, and each part file's header, export const line and };. Every removed line is a moved entry. Nothing else is added or removed.
  • Same keys moved: each part's keys equal its regenerated list in ko, ja and zh (SAME-KEYS). The scan still finds all 1389 keys, the same count as main.
  • Sizes: i18n.ko.ts 513 -> 347, i18n.ja.ts 515 -> 349, i18n.zh.ts 517 -> 351 lines; each devices part 102 lines, each usage part 86 lines (cap 400).
  • HERDR_TEST_MODE=unit bun test src/lib/i18n.test.ts: 21 pass, 0 fail.
  • bun run typecheck: passes.
  • bun run check fast: passes (unit 6127 pass, 0 fail, 12 skip in 434 files, 8 at a time, 58.3s).

Move-only: moved lines, imports, parts entries and part headers.

No changelog fragment: users see no change.

The 93 devices and 77 usage keys that only each feature's files use move, byte for byte, from
src/lib/i18n.{ko,ja,zh}.ts into src/lib/i18n/devices.{ko,ja,zh}.ts and src/lib/i18n/usage.{ko,ja,zh}.ts,
which each base dictionary imports and lists in its parts. KO, JA, ZH, t() and
every call site are unchanged.
@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 57 seconds.

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 b6085f1 and 08107fe.

📒 Files selected for processing: 9
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • src/lib/i18n.zh.ts
  • src/lib/i18n/devices.ja.ts
  • src/lib/i18n/devices.ko.ts
  • src/lib/i18n/devices.zh.ts
  • src/lib/i18n/usage.ja.ts
  • src/lib/i18n/usage.ko.ts
  • src/lib/i18n/usage.zh.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Move-only PR, merged on its required checks without waiting for CodeRabbit (AGENTS.md: a move-only PR merges once its diff shows only moved code and imports).

Merge-gate check on the PR head 08107fe, in a separate checkout:

  • Equivalence: the composed KO/JA/ZH dumped as sorted JSON (i18n-dump.ts) are byte-identical to the merge base: EQUIVALENT.
  • Moved diff: git diff --color-moved=plain origin/main...HEAD shows every removed key line as a move. The only non-moved lines are the part imports, the parts entries and the part file headers.
  • i18n tests: HERDR_TEST_MODE=unit bun test src/lib/i18n.test.ts pass.

Files: src/lib/i18n.ja.ts src/lib/i18n.ko.ts src/lib/i18n.zh.ts src/lib/i18n/devices.ja.ts src/lib/i18n/devices.ko.ts src/lib/i18n/devices.zh.ts src/lib/i18n/usage.ja.ts src/lib/i18n/usage.ko.ts src/lib/i18n/usage.zh.ts

@devswha
devswha merged commit ed8dd59 into main Oct 22, 2026
9 checks passed
@devswha
devswha deleted the refactor/i18n-devices-usage branch October 22, 2026 20:44
devswha added a commit that referenced this pull request Oct 22, 2026
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.
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