Files
HealthLog/src/components/ui/calendar-locale.ts
T
Marc-André Bombeck 41a7f4daea perf(ui): load the date field's calendar when it first opens
react-day-picker and the seven date-fns locales rode the first load of
every page with a date field, the dashboard and the settings sections
among them. The calendar now lives in its own module that the popover
loads on first open; the locale map moves beside it.
2026-10-09 18:22:10 +02:00

30 lines
765 B
TypeScript

import { de, enUS, es, fr, it, ko, pl } from "date-fns/locale";
import type { Locale as DateFnsLocale } from "date-fns";
import type { Locale } from "@/lib/i18n/config";
/**
* Map the app locale → the date-fns locale so the calendar's month / weekday
* names match the UI language. Defaults to enUS for anything unmapped.
* Imported only by the calendars, which load on demand, so the seven
* locales never ride a page's first load.
*/
export function resolveDateFnsLocale(locale: Locale): DateFnsLocale {
switch (locale) {
case "de":
return de;
case "es":
return es;
case "fr":
return fr;
case "it":
return it;
case "pl":
return pl;
case "ko":
return ko;
default:
return enUS;
}
}