feat(web): i18n with react-i18next (sv/en)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-03 22:42:47 +02:00
parent 66d0624279
commit 478b4ce44e
10 changed files with 156 additions and 0 deletions
+18
View File
@@ -3,6 +3,24 @@ import { afterAll, afterEach } from "vitest";
import { server } from "./server";
// Node v26 does not expose localStorage as a global unless --localstorage-file
// is passed. Provide a minimal in-memory shim so i18n and other modules that
// call localStorage.getItem/setItem work in jsdom tests.
if (typeof globalThis.localStorage === "undefined") {
const store: Record<string, string> = {};
Object.defineProperty(globalThis, "localStorage", {
value: {
getItem: (key: string) => store[key] ?? null,
setItem: (key: string, value: string) => { store[key] = value; },
removeItem: (key: string) => { delete store[key]; },
clear: () => { Object.keys(store).forEach((k) => { delete store[k]; }); },
get length() { return Object.keys(store).length; },
key: (i: number) => Object.keys(store)[i] ?? null,
},
writable: true,
});
}
// Start MSW at module level so its fetch patch is in place before any test
// module captures globalThis.fetch via openapi-fetch's createClient().
server.listen({ onUnhandledRequest: "error" });