mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-04 15:04:43 +00:00
fix: date locale can't be loaded if locale is en
This commit is contained in:
@@ -14,9 +14,14 @@ export async function setLocale(locale: Locale, reload = true) {
|
|||||||
export async function setLocaleForLibraries(
|
export async function setLocaleForLibraries(
|
||||||
locale: Locale = (extractLocaleFromCookie() as Locale) || 'en'
|
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([
|
const [zodResult, dateFnsResult] = await Promise.allSettled([
|
||||||
import(`../../../node_modules/zod/v4/locales/${locale}.js`),
|
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') {
|
if (zodResult.status === 'fulfilled') {
|
||||||
|
|||||||
Reference in New Issue
Block a user