fix: force langage for month formatting in stats

fix  #2350
pull/2908/head
Johan Girod 2024-03-01 19:10:33 +01:00
parent 6f55076b6d
commit 743439a3c8
3 changed files with 14 additions and 11 deletions

View File

@ -27,7 +27,10 @@ export const AccessibleTable = ({
formatValue,
caption,
}: AccessibleTableProps) => {
const { t } = useTranslation()
const {
t,
i18n: { language },
} = useTranslation()
return (
<StyledTable as="div">
@ -54,8 +57,8 @@ export const AccessibleTable = ({
<tr key={visite.date}>
<td>
{period === 'mois'
? formatMonth(visite.date)
: formatDay(visite.date)}
? formatMonth(visite.date, language)
: formatDay(visite.date, language)}
</td>
<td>{visite.nombre}</td>
@ -74,8 +77,8 @@ export const AccessibleTable = ({
{visite.date && (
<td>
{period === 'mois'
? formatMonth(visite.date)
: formatDay(visite.date)}
? formatMonth(visite.date, language)
: formatDay(visite.date, language)}
</td>
)}

View File

@ -42,7 +42,7 @@ export function MainIndicators({
return (
<>
<H2>Notre impact en {formatMonth(lastMonth.date)}</H2>
<H2>Notre impact en {formatMonth(lastMonth.date, language)}</H2>
<Grid container spacing={4}>
<Grid item xs={12} md={6}>
<Message border={false} icon={<Emoji emoji="🛎️" />}>
@ -86,7 +86,7 @@ export function MainIndicators({
<Strong>{satisfactionLastMonth?.nbAvisMoyenne}</Strong> avis
reçus
{satisfactionLastMonth?.nbMoisMoyenne === 1
? ` en ${formatMonth(lastMonth.date)}`
? ` en ${formatMonth(lastMonth.date, language)}`
: ` sur les ${satisfactionLastMonth?.nbMoisMoyenne} derniers mois`}
</Body>
</Message>

View File

@ -1,12 +1,12 @@
export function formatDay(date: string | Date) {
return new Date(date).toLocaleString('default', {
export function formatDay(date: string | Date, language: string) {
return new Date(date).toLocaleString(language, {
weekday: 'long',
day: 'numeric',
month: 'long',
})
}
export function formatMonth(date: string | Date) {
return new Date(date).toLocaleString('default', {
export function formatMonth(date: string | Date, language: string) {
return new Date(date).toLocaleString(language, {
month: 'long',
year: 'numeric',
})