diff --git a/apps/manacore/apps/web/src/lib/config/storage-keys.ts b/apps/manacore/apps/web/src/lib/config/storage-keys.ts new file mode 100644 index 000000000..496bd5f8d --- /dev/null +++ b/apps/manacore/apps/web/src/lib/config/storage-keys.ts @@ -0,0 +1,16 @@ +/** + * Centralized localStorage keys for the ManaCore web app. + * All keys should be prefixed with 'manacore-' to avoid collisions. + */ +export const STORAGE_KEYS = { + /** User's preferred locale (e.g., 'de', 'en') */ + LOCALE: 'locale', + /** Whether the sidebar navigation is collapsed */ + NAV_COLLAPSED: 'manacore-nav-collapsed', + /** Whether the welcome page has been seen */ + HAS_SEEN_WELCOME: 'hasSeenWelcome', + /** Onboarding wizard state (JSON) */ + ONBOARDING: 'manacore-onboarding', + /** Dashboard widget layout (JSON) — defined in default-dashboard.ts */ + // DASHBOARD: 'manacore-dashboard-config', +} as const; diff --git a/apps/manacore/apps/web/src/lib/i18n/index.ts b/apps/manacore/apps/web/src/lib/i18n/index.ts index 69ad3c858..275efd602 100644 --- a/apps/manacore/apps/web/src/lib/i18n/index.ts +++ b/apps/manacore/apps/web/src/lib/i18n/index.ts @@ -1,5 +1,6 @@ import { browser } from '$app/environment'; import { init, register, locale, waitLocale } from 'svelte-i18n'; +import { STORAGE_KEYS } from '$lib/config/storage-keys'; // Register all available locales register('de', () => import('./locales/de.json')); @@ -19,7 +20,7 @@ const defaultLocale = 'de'; function getInitialLocale(): SupportedLocale { if (browser) { // Check localStorage first - const stored = localStorage.getItem('locale'); + const stored = localStorage.getItem(STORAGE_KEYS.LOCALE); if (stored && supportedLocales.includes(stored as SupportedLocale)) { return stored as SupportedLocale; } @@ -52,7 +53,7 @@ export function initI18n() { export function setLocale(newLocale: SupportedLocale) { locale.set(newLocale); if (browser) { - localStorage.setItem('locale', newLocale); + localStorage.setItem(STORAGE_KEYS.LOCALE, newLocale); } }