Skip to content
Snippets Groups Projects
Commit 997dd579 authored by Léopold Chappuis's avatar Léopold Chappuis Committed by Adrien Béraud
Browse files

locales: fix invalid languageTag

Change-Id: I21d27522f034e21a71f48e38ac6c6daae49a8bd2
parent 3b1bd631
No related branches found
No related tags found
No related merge requests found
...@@ -24,12 +24,15 @@ export const formatTime = (time: Dayjs, i18n: i18n) => { ...@@ -24,12 +24,15 @@ export const formatTime = (time: Dayjs, i18n: i18n) => {
} }
export const formatRelativeDate = (time: Dayjs, i18n: i18n) => { export const formatRelativeDate = (time: Dayjs, i18n: i18n) => {
let languageTag = i18n.language
languageTag = languageTag.replace(/_/g, '-')
if (time.isToday()) { 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()) { } 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 { } else {
return dayjs(time).locale(i18n.language).format('L') return dayjs(time).locale(languageTag).format('L')
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment