picker
picker copied to clipboard
fix: map to correct locales for date-fns
Resolves https://github.com/react-component/picker/issues/147
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
Hello, we ran into the mentioned bug and wondered if there's anything preventing this PR from being merged?
@zombieJ ? 👀
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!
@MadCcc would it be possible to merge this PR?
Is that a more common way to auto generate locale? Seems this will has much maintain effort if enum all the locale.
const dealLocal = (str: string) => {
const head = str.slice(0, str.indexOf('_'));
return Locale.hasOwnProperty(head) ? head : str.replace(/_/g, '');
}
Maybe this way?
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.
[REDACTED]
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
Rebase please.
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;
};
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 |
Rebase please.
Rebased and updated with the latest locales.
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.
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.