perf(i18n): lazy-load locale catalogs instead of bundling every language (#2362)

Co-authored-by: Kandev Agent <agent@kandev.dev>
This commit is contained in:
João Salavisa
2026-08-07 19:43:42 +02:00
committed by GitHub
parent 224206e6d8
commit d855d615f8
10 changed files with 675 additions and 44 deletions
+10 -1
View File
@@ -5,6 +5,8 @@ import { setOnUnauthorized } from "@/lib/api/client";
import { PluginModalHost } from "@/components/plugins/plugin-modal-host";
import { useAppStoreApi, StateProvider } from "@/components/state-provider";
import { PluginBootBridge } from "@/lib/plugins/plugin-boot-bridge";
import { preloadLocale } from "@/lib/i18n";
import { resolveInitialLocale } from "@/lib/i18n/boot";
import { AppShell } from "./app-shell";
import { AuthGatedScreen, useAuthGateDecision } from "./auth-gate";
import { loadBootPayload } from "./boot-payload";
@@ -67,7 +69,14 @@ if (!root) {
throw new Error("Missing #root element");
}
void loadBootPayload().then((payload) => {
void loadBootPayload().then(async (payload) => {
// Only `en` ships in the entry chunk, so a non-English boot has to fetch its
// catalogs. Awaited HERE, in the promise the mount already waited on, rather
// than after mounting: with `returnNull: false` a missing key renders as the
// key itself, so rendering first would paint a frame of raw `common:save`
// strings. Resolves immediately for `en` — the common case is unchanged.
await preloadLocale(resolveInitialLocale(payload));
createRoot(root).render(
<StrictMode>
<RootErrorBoundary>