Merge pull request #1721 from sunaurus/date_fns_lang

Fix date-fns locale import failing for some locales
This commit is contained in:
SleeplessOne1917 2023-06-30 15:11:37 -04:00 committed by GitHub
commit 93fe23a305
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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$/ */