From fb85af44e256bbe4d8fff5bea63c99de4a775312 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 19 Apr 2026 19:30:01 +0300 Subject: [PATCH] fix(standalone): change locale after DB init --- apps/client-standalone/src/local-server-worker.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/client-standalone/src/local-server-worker.ts b/apps/client-standalone/src/local-server-worker.ts index 77092cff65..6431b0354f 100644 --- a/apps/client-standalone/src/local-server-worker.ts +++ b/apps/client-standalone/src/local-server-worker.ts @@ -294,6 +294,20 @@ async function initialize(): Promise { if (coreModule.sql_init.isDbInitialized()) { console.log("[Worker] Database already initialized, loading becca..."); await coreModule.becca_loader.beccaLoaded; + + // `initTranslations` runs before `initSql` inside `initializeCore` + // (options_init needs translations, creating a chicken-and-egg), + // so it always defaults to "en" on a fresh worker boot. Now that + // the DB is up we can read the real locale and, if it differs, + // switch i18next and rebuild the hidden subtree with the correct + // titles. This must happen BEFORE `startScheduler` registers its + // own `dbReady.then(checkHiddenSubtree)` so the scheduled rebuild + // sees the right language. + const dbLocale = coreModule.options.getOptionOrNull("locale"); + if (dbLocale && dbLocale !== "en") { + console.log(`[Worker] Reconciling i18next locale to "${dbLocale}" from DB`); + await coreModule.i18n.changeLanguage(dbLocale); + } } else { console.log("[Worker] Database not initialized, skipping becca load (will be loaded during DB initialization)"); }