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: map to correct locales for date-fns #289

Closed
wants to merge 2 commits into from

Conversation

spawnia
Copy link

@spawnia spawnia commented Aug 26, 2021

Resolves #147

@vercel
Copy link

vercel bot commented Aug 26, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/react-component/picker/9cVHdkzQDnwLP9gPECRu16mC7oVy
✅ Preview: https://picker-git-fork-mll-lab-date-fns-locale-react-component.vercel.app

@aequi42
Copy link

aequi42 commented Oct 11, 2021

Hello, we ran into the mentioned bug and wondered if there's anything preventing this PR from being merged?

@israelKusayev
Copy link

@zombieJ ? 👀

@Saarnaki
Copy link

Why has this not been merged? This change would solve the issue for several locales. Spawnia has done the tedious work of mapping the locales, why not reap the benefit already? Really need this for our product!

@tvojtech
Copy link

tvojtech commented Mar 1, 2022

@MadCcc would it be possible to merge this PR?

@zombieJ
Copy link
Member

zombieJ commented Mar 10, 2022

Is that a more common way to auto generate locale? Seems this will has much maintain effort if enum all the locale.

@MadCcc
Copy link
Member

MadCcc commented Mar 10, 2022

const dealLocal = (str: string) => {
  const head = str.slice(0, str.indexOf('_'));
  return Locale.hasOwnProperty(head) ? head : str.replace(/_/g, '');
}

Maybe this way?

@spawnia
Copy link
Author

spawnia commented Mar 10, 2022

I thought about a generalized solution, but in this case it is not worth it. Creating this pull request took me a few minutes of (admittedly tedious) work, but saved the time required to think through, test and future-proof another solution. The addition or removal of future locales should not happen often, and will be very easy to do and require little to no thought or testing.

@henrikskog
Copy link

henrikskog commented Jul 4, 2022

[REDACTED]

@fasenderos
Copy link

Hello, 2 years later the #147 we are facing the same bug for the it_IT.

const dealLocal = (str: string) => {
  const head = str.slice(0, str.indexOf('_'));
  return Locale.hasOwnProperty(head) ? head : str.replace(/_/g, '');
}

Maybe this way?

The solution proposed by @MadCcc seems more general and would solve the issue for all locales. Really need this thanks

@yoyo837
Copy link
Member

yoyo837 commented Feb 21, 2024

Rebase please.

@lihue
Copy link

lihue commented Feb 21, 2024

this works for me:

const dealLocal = (locale: string) => {
  const loc = locale.replace(/_/g, '');
  const head = locale.slice(0, locale.indexOf('_'));
  return Locale[loc] ? loc : head;
};

Copy link

vercel bot commented Feb 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
picker ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2024 10:29am

@spawnia
Copy link
Author

spawnia commented Feb 21, 2024

Rebase please.

Rebased and updated with the latest locales.

Copy link

codecov bot commented Feb 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b0e8561) 98.57% compared to head (e473a66) 98.57%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #289      +/-   ##
==========================================
- Coverage   98.57%   98.57%   -0.01%     
==========================================
  Files          63       63              
  Lines        2534     2530       -4     
  Branches      671      670       -1     
==========================================
- Hits         2498     2494       -4     
  Misses         33       33              
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zombieJ
Copy link
Member

zombieJ commented Feb 23, 2024

I've checked the locale file find that @MadCcc maybe the better solution. Please help check on this: #763

For example, manually map the ar_EG to ar is not correct for the weekStartsOn. The arEG is 0 but ar is 6. It should always use the full path match and then fallback to the abbr version.

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.

generateConfig for date-fns throws error for some locales