projects
/
lemmy-ui.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
cf9f37f
)
Fix date-fns locale import failing for some locales
author
sunaurus
<sander@saarend.com>
Fri, 30 Jun 2023 16:59:44 +0000
(19:59 +0300)
committer
sunaurus
<sander@saarend.com>
Fri, 30 Jun 2023 16:59:44 +0000
(19:59 +0300)
src/shared/utils/app/setup-date-fns.ts
patch
|
blob
|
history
diff --git
a/src/shared/utils/app/setup-date-fns.ts
b/src/shared/utils/app/setup-date-fns.ts
index fe9572051edc459225449d04e13b8d5a4bde761e..44f27acfe61c91c7a50fa4872b3bb4fa7d32182c 100644
(file)
--- 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$/ */