mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-19 01:01:30 +02:00
- Add PillNavigation component from @manacore/shared-ui - Create theme store with purple color scheme - Add i18n support (DE/EN) with svelte-i18n - Integrate theme switching, language selector, app switcher - Add glassmorphic utility classes to app.css - Update layouts to match other apps' navigation pattern Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import { browser } from '$app/environment';
|
|
import { init, register, locale, waitLocale } from 'svelte-i18n';
|
|
|
|
// List of supported locales
|
|
export const supportedLocales = ['de', 'en'] as const;
|
|
export type SupportedLocale = (typeof supportedLocales)[number];
|
|
|
|
// Default locale
|
|
const defaultLocale = 'de';
|
|
|
|
// Register all available locales
|
|
register('de', () => import('./locales/de.json'));
|
|
register('en', () => import('./locales/en.json'));
|
|
|
|
// Get initial locale from browser or localStorage
|
|
function getInitialLocale(): SupportedLocale {
|
|
if (browser) {
|
|
// Check localStorage first
|
|
const stored = localStorage.getItem('matrix_locale');
|
|
if (stored && supportedLocales.includes(stored as SupportedLocale)) {
|
|
return stored as SupportedLocale;
|
|
}
|
|
|
|
// Fall back to browser language
|
|
const browserLang = navigator.language.split('-')[0];
|
|
if (supportedLocales.includes(browserLang as SupportedLocale)) {
|
|
return browserLang as SupportedLocale;
|
|
}
|
|
}
|
|
|
|
return defaultLocale;
|
|
}
|
|
|
|
// Initialize i18n at module scope (required for SSR)
|
|
init({
|
|
fallbackLocale: defaultLocale,
|
|
initialLocale: getInitialLocale(),
|
|
});
|
|
|
|
// Set locale and persist to localStorage
|
|
export function setLocale(newLocale: SupportedLocale) {
|
|
locale.set(newLocale);
|
|
if (browser) {
|
|
localStorage.setItem('matrix_locale', newLocale);
|
|
}
|
|
}
|
|
|
|
// Wait for locale to be loaded (useful for SSR)
|
|
export { waitLocale };
|