felixmosh / bull-board

🎯 Queue background jobs inspector
MIT License
2.36k stars 366 forks source link

Fix dateFnsLocale for French and Spanish languages for job duration #836

Closed difagume closed 1 month ago

difagume commented 1 month ago

Looking at the console, I saw that dateFns couldn't find the locale for es-ES and fr-FR since in its languages it only has them as: es and fr. Because of this, the work progress is shown in English.

1 image image

The error line is:

async function setDateFnsLocale(lng: string) {
  dateFnsLocale = await import(`date-fns/locale/${lng}/index.js`).catch((e) => console.error(e));
}

I renamed the language values for proper visualization and reordered them alphabetically.

image image image

The other option would be to just adjust the setDateFnsLocale() code to:

async function setDateFnsLocale(lng: string) {
  if(lng==='es-ES') lng='es';
  if(lng==='fr-FR') lng='fr';
  dateFnsLocale = await import(`date-fns/locale/${lng}/index.js`).catch((e) => console.error(e));
}
felixmosh commented 1 month ago

Hi, great catch! Can you change this PR to

async function setDateFnsLocale(lng: string) {
  if(lng==='es-ES') lng='es';
  if(lng==='fr-FR') lng='fr';
  dateFnsLocale = await import(`date-fns/locale/${lng}/index.js`).catch((e) => console.error(e));
}
felixmosh commented 1 month ago

Thank u for this FIX