🐛 fix(clock): fix i18n initialization and add missing nav icons

- Fix svelte-i18n locale loading error by waiting for locale before render
- Add isLocaleLoading check to prevent rendering before translations ready
- Export waitLocale from i18n module for proper async initialization

- Add missing icons to PillNavigation component:
  - bell, timer, stopwatch, target, globe for Clock app
  - inbox, check, checkCircle, plus for Todo app

- Update Clock navItems to use proper icons:
  - Timer: clock → timer
  - Stoppuhr: activity → stopwatch

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Till-JS 2025-12-03 16:11:01 +01:00
parent 2126cd5d3c
commit 8dcf543ed4
3 changed files with 37 additions and 6 deletions

View file

@ -40,7 +40,7 @@ function getInitialLocale(): SupportedLocale {
return 'de';
}
// Initialize
// Initialize i18n at module scope (required for SSR)
init({
fallbackLocale: 'de',
initialLocale: getInitialLocale(),
@ -53,3 +53,6 @@ export function setLocale(newLocale: SupportedLocale) {
localStorage.setItem('clock-locale', newLocale);
}
}
// Wait for locale to be loaded (useful for SSR)
export { waitLocale } from 'svelte-i18n';

View file

@ -2,7 +2,7 @@
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { onMount } from 'svelte';
import { locale } from 'svelte-i18n';
import { locale, isLoading as isLocaleLoading } from 'svelte-i18n';
import { PillNavigation } from '@manacore/shared-ui';
import type { PillNavItem, PillDropdownItem } from '@manacore/shared-ui';
import { theme } from '$lib/stores/theme.svelte';
@ -14,7 +14,7 @@
} from '$lib/stores/navigation';
import { getLanguageDropdownItems, getCurrentLanguageLabel } from '@manacore/shared-i18n';
import { getPillAppItems } from '@manacore/shared-branding';
import { setLocale, supportedLocales } from '$lib/i18n';
import { setLocale, supportedLocales, waitLocale } from '$lib/i18n';
import ToastContainer from '$lib/components/ToastContainer.svelte';
import '../app.css';
@ -77,8 +77,8 @@
const navItems: PillNavItem[] = [
{ href: '/', label: 'Übersicht', icon: 'home' },
{ href: '/alarms', label: 'Wecker', icon: 'bell' },
{ href: '/timers', label: 'Timer', icon: 'clock' },
{ href: '/stopwatch', label: 'Stoppuhr', icon: 'activity' },
{ href: '/timers', label: 'Timer', icon: 'timer' },
{ href: '/stopwatch', label: 'Stoppuhr', icon: 'stopwatch' },
{ href: '/pomodoro', label: 'Pomodoro', icon: 'target' },
{ href: '/world-clock', label: 'Weltzeituhr', icon: 'globe' },
{ href: '/settings', label: 'Einstellungen', icon: 'settings' },
@ -137,6 +137,9 @@
}
onMount(async () => {
// Wait for locale to be loaded
await waitLocale();
// Initialize theme
theme.initialize();
@ -165,10 +168,21 @@
<ToastContainer />
{#if isAuthRoute}
{#if $isLocaleLoading}
<!-- Wait for locale to be loaded -->
<div class="flex min-h-screen items-center justify-center bg-background">
<div class="text-center">
<div
class="mb-4 inline-block h-12 w-12 animate-spin rounded-full border-4 border-solid border-primary border-r-transparent"
></div>
<p class="text-muted-foreground">Laden...</p>
</div>
</div>
{:else if isAuthRoute}
<!-- Auth routes: no navigation, just render content -->
{@render children()}
{:else if loading}
<!-- App initialization loading -->
<div class="flex min-h-screen items-center justify-center bg-background">
<div class="text-center">
<div