From ed1f208e47e17eaadba3008c4396aea820520662 Mon Sep 17 00:00:00 2001 From: sunaurus Date: Fri, 30 Jun 2023 19:59:44 +0300 Subject: [PATCH] Fix date-fns locale import failing for some locales --- src/shared/utils/app/setup-date-fns.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/shared/utils/app/setup-date-fns.ts b/src/shared/utils/app/setup-date-fns.ts index fe95720..44f27ac 100644 --- a/src/shared/utils/app/setup-date-fns.ts +++ b/src/shared/utils/app/setup-date-fns.ts @@ -7,6 +7,16 @@ export default async function () { lang = "en-US"; } + // if lang and country are the same, then date-fns expects only the lang + // eg: instead of "fr-FR", we should import just "fr" + + if (lang.includes("-")) { + const parts = lang.split("-"); + if (parts[0] === parts[1].toLowerCase()) { + lang = parts[0]; + } + } + const locale = ( await import( /* webpackExclude: /\.js\.flow$/ */ -- 2.44.1