Repository navigation
i18n: lazy-load bundled locale catalogs and cache proxy/i18n tests - #1310
Conversation
Aymericr
left a comment
There was a problem hiding this comment.
[Maintainer] Thanks @kruschdev for picking up the #1148 review follow-ups (this one closes #1155). Status at ef2da6b:
- Merge conflicts. The branch is
dirtyagainstmain; please rebase. Note that #1289 (wall chaining and lazy editor startup) also changesclient-bootstrap.tsxandlazy-locales.ts, so whichever lands second will need to resolve against the other. - Bugbot (Medium) at ef2da6b:
client-bootstrap.tsxswitches the active locale before its catalog has loaded, so there can be a flash of untranslated ids or a failed load that leaves the UI on a locale with no messages. Switch after the catalog resolves, and fall back to the previous locale on failure. - Screenshots are present; thank you.
CI: GitHub Actions have not run on this head (fork workflows are waiting for maintainer approval).
|
[Maintainer] One scope note at ef2da6b, on top of the status above. This PR bundles four independent changes that all came from the #1148 review (20 files, +789 / -49): (a) stricter placeholder / tag / ICU-select validation in They touch different packages and can be reverted separately. Please split into: 1) (a) alone, a tooling-only PR; 2) (c) alone, a core-only PR; 3) (b), the lazy locale loading. #1289 also adds lazy locale loading ( |
|
[Maintainer] Correction to my comment above: I hadn't verified that slices 1 and 2 need no conflict work. The branch currently conflicts with |
ef2da6b to
3a2a5b3
Compare
|
Thanks @Aymericr! I rebased onto
On the Bugbot finding in Verified locally after rebase: |
|
Thanks @kruschdev. Update at head 3a2a5b3: the i18n validation changes that used to be in this PR have now landed through #1347 (#1344) and #1348, so this is no longer a duplicate of them. What remains here is the lazy-loaded per-locale catalog entry points, the active-locale-only server-to-client handoff, the |
|
Review at
P0/P1: 0. CI hasn't run on this fork PR yet because it needs a maintainer to approve the workflow run; it merges once that's green. |
…rden ClientBootstrap retry
… switches, and widen turbo inputs
3a2a5b3 to
a1b11b6
Compare
|
Thanks for the thorough review. I rebased onto
Verified green with |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a1b11b6. Configure here.
…e on new apply, and add editor entry turbo inputs
|
Pushed
Verified green locally with |

Summary
Remaining follow-up slice from #1148 after the i18n validation (#1344 / #1347 / #1348) and fallback plural rules (#1345 / #1350) landed on
main:@pascal-app/editor/locales/lazy(loadBundledLocale,isBundledLocaleLoaded,registerBundledCatalog,resolveBundledLocale,loadAllBundledLocales) plus per-locale entry points (@pascal-app/editor/locales/{en,es,fr,ja,zh-CN}) while preserving the synchronous@pascal-app/editor/localesentry (bundledLocalePacksandregisterBundledLocales(): void).apps/editor: UpdatedRootLayoutandClientBootstrapso the app loads only the active locale catalog initially and dynamically loads switched locales on?lang=navigation ordefaultI18n.setLocale(...), with stale-request cancellation and offline/reconnect retry.//#test:i18n-scriptsinturbo.jsonwith explicitinputsandproxy.test.tscoverage for?lang=forwarding and client navigation.Verification
bun run check-types(14/14 packages)bun test --randomize packages/editor/src/i18n/locales.test.ts apps/editor/lib/ui-locale.test.ts apps/editor/proxy.test.ts(28/28 pass)bun test scripts/i18n.test.ts scripts/i18n-provider.test.ts scripts/i18n-literals.test.ts scripts/biome-architecture-plugins.test.ts(224/224 pass)bun run skills:validateand Biome check cleanNote
Medium Risk
Touches i18n hydration, client navigation, and middleware locale headers—user-visible if loading or ?lang= handling regresses, but behavior is heavily tested and failures are designed to leave the active locale unchanged.
Overview
Replaces eager registration of all five translation catalogs with lazy loading via
@pascal-app/editor/locales/lazyand per-locale package exports, so the initial client bundle only pays for the active locale.Server + client bootstrap:
RootLayoutnowloadBundledLocales the resolved locale and passesinitialCatalogintoClientBootstrap, which registers that catalog beforecreateI18ninstead of callingregisterBundledLocales()at module load.Runtime locale changes:
ClientBootstrapaddsLocaleQuerySync(wrapped inSuspense) to react to?lang=without full reloads, pluscreateLocaleApplierto load catalogs beforesetLocale, cancel superseded switches, and retry failed loads ononline/focus. ImperativedefaultI18nlocale changes use the same applier path.Tests & CI: New
ui-localeunit tests, expanded lazy-locale andproxy()coverage for canonicalized?lang=/x-pascal-localeforwarding, and a Turbo//#test:i18n-scriptstask with explicit inputs; roottestscript routes i18n script tests through that cacheable target.Reviewed by Cursor Bugbot for commit 9bd6add. Bugbot is set up for automated code reviews on this repo. Configure here.