Allow setting default locale for DatePicker
See original GitHub issueSummary
Is it possible to set default locale for DatePicker
? Then we don’t need to pass locale
to each DatePicker
component.
Justification
No.
Desired UX and success metrics
Probably we can add a function to set default locale?
import { DatePicker } from "carbon-components-react";
DatePicker.setDefaultLocale("zh_tw");
“Must have” functionality
Set default locale for DatePicker
Specific timeline issues / requests
We have a GVT defect in our backlog. It’s up to this ticket to decide whether we should directly fix this defect by adding locale
prop to each DatePicker
.
Available extra resources
What resources do you have to assist this effort?
I guess we probably can discuss the better way to do this. If needed, I can create a PR for it.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
android - Set default Locale to DatePicker and TimePicker
I want to either change localization of DatePicker and TimePicker to English all the time, Or to change it to Arabic when the...
Read more >Locale support(DatePicker) needs better locale support
Summary There needs to be more supported locales, and better logic in determining which locale to use. This is a development request.
Read more >DatePicker
Default locale is en , to change this follow dayjs localization guide: // First import locale data. import 'dayjs/locale/ru';. Then set locale prop...
Read more >Date and Time pickers - Localization
Date and Time pickers allow to support users from different locales, with formatting, RTL, and localized strings. The default locale of MUI is...
Read more >How to set a Date picker language format instead of using local
I would like all my Date pickers to be displayed in english language i.e Jun-2020 irrespective of the user's local language. Formula on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @fred104 sorry for the delay in responding. If I understand correctly, you’d like to set a new default locale for all DatePickers in your application.
If this is the case, I’d recommend creating a lightweight wrapper around DatePicker that would set the locale to your preferred locale. You can then reuse this wrapper throughout your application in place of DatePicker. Something like this might work:
Here’s a quick codesandbox example I cooked up.
Closing this issue, since this is not a bug and no enhancement is needed. For anyone else wanting to do a similar thing, we’ve provided the recommended solution above for setting the same prop value to more than one component without having to explicitly add the prop to each component instance (see https://github.com/carbon-design-system/carbon/issues/9248#issuecomment-916371174)