diff --git a/packages/ui/src/components/JobCard/Timeline/Timeline.tsx b/packages/ui/src/components/JobCard/Timeline/Timeline.tsx index 493355b4..fe398c77 100644 --- a/packages/ui/src/components/JobCard/Timeline/Timeline.tsx +++ b/packages/ui/src/components/JobCard/Timeline/Timeline.tsx @@ -1,5 +1,4 @@ import { formatDistance, isToday, differenceInMilliseconds, format, isSameYear } from 'date-fns'; -import enLocale from 'date-fns/locale/en-US'; import { TFunction } from 'i18next'; import React from 'react'; import { useTranslation } from 'react-i18next'; @@ -57,7 +56,7 @@ const formatDuration = (finishedTs: TimeStamp, processedTs: TimeStamp, t: TFunct if (durationInSeconds > 5) { return formatDistance(finishedTs, processedTs, { includeSeconds: true, - locale: dateFnsLocale || enLocale, + locale: dateFnsLocale, }); } if (durationInSeconds >= 1) { diff --git a/packages/ui/src/services/i18n.ts b/packages/ui/src/services/i18n.ts index c4a877b4..f608298b 100644 --- a/packages/ui/src/services/i18n.ts +++ b/packages/ui/src/services/i18n.ts @@ -2,8 +2,9 @@ import i18n from 'i18next'; import HttpBackend from 'i18next-http-backend'; import * as process from 'process'; import { initReactI18next } from 'react-i18next'; +import enLocale from 'date-fns/locale/en-US'; -export let dateFnsLocale = undefined; +export let dateFnsLocale = enLocale; const dateFnsLocaleMap = { 'es-ES': 'es', 'fr-FR': 'fr', @@ -11,9 +12,12 @@ const dateFnsLocaleMap = { async function setDateFnsLocale(lng: string) { const languageToLoad = dateFnsLocaleMap[lng as keyof typeof dateFnsLocaleMap] || lng; - dateFnsLocale = await import(`date-fns/locale/${languageToLoad}/index.js`).catch((e) => - console.error(e) - ); + dateFnsLocale = await import(`date-fns/locale/${languageToLoad}/index.js`).catch((e) => { + // eslint-disable-next-line no-console + console.info(e); + + return enLocale; + }); } export async function initI18n({ lng, basePath }: { lng: string; basePath: string }) {