diff --git a/public/pages/dashboard.js b/public/pages/dashboard.js index ba0aaae..855a265 100644 --- a/public/pages/dashboard.js +++ b/public/pages/dashboard.js @@ -5,6 +5,7 @@ */ import { api } from '/api.js'; +import { t } from '/i18n.js'; // Hält den AbortController des aktuellen FAB-Listeners — wird bei jedem render() erneuert. let _fabController = null; @@ -15,8 +16,9 @@ let _fabController = null; function greeting(displayName) { const h = new Date().getHours(); - const tageszeit = h < 12 ? 'Morgen' : h < 18 ? 'Tag' : 'Abend'; - return `Guten ${tageszeit}, ${displayName}`; + if (h < 12) return t('dashboard.greetingMorning', { name: displayName }); + if (h < 18) return t('dashboard.greetingDay', { name: displayName }); + return t('dashboard.greetingEvening', { name: displayName }); } function formatDate(date = new Date()) { @@ -49,21 +51,21 @@ function formatDueDate(dateStr) { const diffMs = due - now; const diffH = diffMs / (1000 * 60 * 60); - if (diffMs < 0) return { text: 'Überfällig', overdue: true }; - if (diffH < 24) return { text: 'Heute fällig', overdue: false }; - if (diffH < 48) return { text: 'Morgen fällig', overdue: false }; + if (diffMs < 0) return { text: t('dashboard.overdue'), overdue: true }; + if (diffH < 24) return { text: t('dashboard.dueSoon'), overdue: false }; + if (diffH < 48) return { text: t('dashboard.dueTomorrow'), overdue: false }; return { text: due.toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit' }), overdue: false, }; } -const MEAL_LABELS = { - breakfast: 'Frühstück', - lunch: 'Mittagessen', - dinner: 'Abendessen', - snack: 'Snack', -}; +const MEAL_LABELS = () => ({ + breakfast: t('meals.typeBreakfast'), + lunch: t('meals.typeLunch'), + dinner: t('meals.typeDinner'), + snack: t('meals.typeSnack'), +}); const MEAL_ICONS = { breakfast: 'sunrise', @@ -76,7 +78,8 @@ function initials(name = '') { return name.split(' ').map((w) => w[0]).join('').slice(0, 2).toUpperCase(); } -function widgetHeader(icon, title, count, linkHref, linkLabel = 'Alle') { +function widgetHeader(icon, title, count, linkHref, linkLabel) { + linkLabel = linkLabel ?? t('dashboard.allLink'); const badge = count != null ? `` : ''; @@ -122,17 +125,17 @@ function renderGreeting(user, stats = {}) { if (urgentCount > 0) statChips.push(` - ${urgentCount} dring. Aufgabe${urgentCount > 1 ? 'n' : ''} + ${urgentCount > 1 ? t('dashboard.urgentTasksChipPlural', { count: urgentCount }) : t('dashboard.urgentTasksChip', { count: urgentCount })} `); if (todayEventCount > 0) statChips.push(` - ${todayEventCount} Termin${todayEventCount > 1 ? 'e' : ''} heute + ${todayEventCount > 1 ? t('dashboard.eventsChipPlural', { count: todayEventCount }) : t('dashboard.eventsChip', { count: todayEventCount })} `); if (todayMealTitle) statChips.push(` - Heute: ${todayMealTitle} + ${t('dashboard.todayMealChip', { title: todayMealTitle })} `); return ` @@ -149,10 +152,10 @@ function renderGreeting(user, stats = {}) { function renderUrgentTasks(tasks) { if (!tasks.length) { return `
`; } @@ -174,7 +177,7 @@ function renderUrgentTasks(tasks) { }).join(''); return ``; } @@ -182,10 +185,10 @@ function renderUrgentTasks(tasks) { function renderUpcomingEvents(events) { if (!events.length) { return ``; } @@ -194,14 +197,14 @@ function renderUpcomingEvents(events) { const items = events.map((e) => { const d = new Date(e.start_datetime); const isToday = d.toDateString() === today; - const timeStr = e.all_day ? 'Ganztägig' : d.toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' }) + ' Uhr'; + const timeStr = e.all_day ? t('dashboard.allDay') : d.toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' }) + ' Uhr'; return `