picker icon indicating copy to clipboard operation
picker copied to clipboard

fix: map to correct locales for date-fns

Open spawnia opened this issue 2 years ago • 9 comments

Resolves https://github.com/react-component/picker/issues/147

spawnia avatar Aug 26 '21 19:08 spawnia

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

vercel[bot] avatar Aug 26 '21 19:08 vercel[bot]

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

aequi42 avatar Oct 11 '21 12:10 aequi42

@zombieJ ? 👀

israelKusayev avatar Oct 29 '21 07:10 israelKusayev

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!

Saarnaki avatar Dec 29 '21 15:12 Saarnaki

@MadCcc would it be possible to merge this PR?

tvojtech avatar Mar 01 '22 12:03 tvojtech

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

zombieJ avatar Mar 10 '22 03:03 zombieJ

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

Maybe this way?

MadCcc avatar Mar 10 '22 04:03 MadCcc

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.

spawnia avatar Mar 10 '22 08:03 spawnia

[REDACTED]

henrikskog avatar Jul 04 '22 13:07 henrikskog

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

fasenderos avatar Oct 26 '22 08:10 fasenderos

Rebase please.

yoyo837 avatar Feb 21 '24 09:02 yoyo837

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;
};

lihue avatar Feb 21 '24 09:02 lihue

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

vercel[bot] avatar Feb 21 '24 10:02 vercel[bot]

Rebase please.

Rebased and updated with the latest locales.

spawnia avatar Feb 21 '24 10:02 spawnia

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 21 '24 10:02 codecov[bot]

I've checked the locale file find that @MadCcc maybe the better solution. Please help check on this: https://github.com/react-component/picker/pull/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.

zombieJ avatar Feb 23 '24 02:02 zombieJ