From b81de451668c425bfc5ca7cd6071fe2756b31594 Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Fri, 3 Oct 2025 11:54:07 +0200 Subject: [PATCH] fix: date locale can't be loaded if locale is `en` --- frontend/src/lib/utils/locale.util.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/utils/locale.util.ts b/frontend/src/lib/utils/locale.util.ts index 5141f9fa..31b28601 100644 --- a/frontend/src/lib/utils/locale.util.ts +++ b/frontend/src/lib/utils/locale.util.ts @@ -14,9 +14,14 @@ export async function setLocale(locale: Locale, reload = true) { export async function setLocaleForLibraries( locale: Locale = (extractLocaleFromCookie() as Locale) || 'en' ) { + let dateFnsLocale: string = locale; + if (dateFnsLocale === 'en') { + dateFnsLocale = 'en-US'; // datefns doesn't have 'en' + } + const [zodResult, dateFnsResult] = await Promise.allSettled([ import(`../../../node_modules/zod/v4/locales/${locale}.js`), - import(`../../../node_modules/date-fns/locale/${locale}.js`) + import(`../../../node_modules/date-fns/locale/${dateFnsLocale}.js`) ]); if (zodResult.status === 'fulfilled') {