Repository navigation
refactor(i18n): move devices and usage-only strings into src/lib/i18n/ - #1681
Conversation
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.
|
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 57 seconds. View limit details
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. Comment |
|
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:
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 |
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.
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}.tsandsrc/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
components/DevicesPanel.tsx(with VIA),components/PhonePanel.tsx,components/PortalPanel.tsx,components/PushTestControls.tsx,components/AccessGate.tsx,components/LanExposureNotice.tsx,lib/install.ts.components/UsageSettings.tsx,components/UsageAccountDialog.tsx,components/UsageLocalLogin.tsx,components/UsageHubConnect.tsx,components/CLIProxyLogin.tsx,components/UsageMeters.tsx,lib/usage.ts(with WINDOW_LABEL).KO_PARTS/JA_PARTS/ZH_PARTSentries. 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 asi18n.test.tsdoes:t()/tt()literals plus the 13 label maps, per file):Checks
KO,JAandZH(every key and value) dumped as sorted JSON onb6085f11and on this branch are byte-identical (EQUIVALENT).--color-movedsummary:git diff --color-moved=plain origin/main...HEADover 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 constline and};. Every removed line is a moved entry. Nothing else is added or removed.SAME-KEYS). The scan still finds all 1389 keys, the same count as main.i18n.ko.ts513 -> 347,i18n.ja.ts515 -> 349,i18n.zh.ts517 -> 351 lines; eachdevicespart 102 lines, eachusagepart 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.