Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Oct 16, 2024

Conversation

difagume
Copy link
Contributor

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
Copy link
Owner

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 felixmosh merged commit 21129ab into felixmosh:master Oct 16, 2024
4 checks passed
@felixmosh
Copy link
Owner

Thank u for this FIX

@difagume difagume deleted the dateFnsLocale-fix branch October 16, 2024 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants