1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-02-04 11:36:46 +00:00

fix: date locale can't be loaded if locale is en

This commit is contained in:
Elias Schneider
2025-10-03 11:54:07 +02:00
parent 22f4254932
commit b81de45166

View File

@@ -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') {