From 997dd57953aa32bf8de95c7fe44c45f3183c6225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o?= <leopold.chappuis@savoirfairelinux.com> Date: Thu, 13 Feb 2025 16:35:37 -0500 Subject: [PATCH] locales: fix invalid languageTag Change-Id: I21d27522f034e21a71f48e38ac6c6daae49a8bd2 --- client/src/utils/dates×.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/utils/dates×.ts b/client/src/utils/dates×.ts index 89dfae0a..cbdd2fd2 100644 --- a/client/src/utils/dates×.ts +++ b/client/src/utils/dates×.ts @@ -24,12 +24,15 @@ export const formatTime = (time: Dayjs, i18n: i18n) => { } export const formatRelativeDate = (time: Dayjs, i18n: i18n) => { + let languageTag = i18n.language + languageTag = languageTag.replace(/_/g, '-') + if (time.isToday()) { - return new Intl.RelativeTimeFormat(i18n.language, { numeric: 'auto' }).format(0, 'day') + return new Intl.RelativeTimeFormat(languageTag, { numeric: 'auto' }).format(0, 'day') } else if (time.isYesterday()) { - return new Intl.RelativeTimeFormat(i18n.language, { numeric: 'auto' }).format(-1, 'day') + return new Intl.RelativeTimeFormat(languageTag, { numeric: 'auto' }).format(-1, 'day') } else { - return dayjs(time).locale(i18n.language).format('L') + return dayjs(time).locale(languageTag).format('L') } } -- GitLab