You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: I haven't tested these APIs, how they work with different browser UI language and OS language etc.
On a last note, theoritically the user could have this setup too: OS based on en-us but dates and numbers formatting set to a european format eg el-GR. I am not sure if there is a way to detect this setup.
The text was updated successfully, but these errors were encountered:
sledgehammer999
changed the title
Calendar/Date components: Default locale to user preference
Calendar/Date components: Default locale to user lang preference
Oct 21, 2024
I've considered this, but I've felt it might be a bit too invasive when it can be accomplished in user-land via a single locale prop.
My reasons for thinking this way is, say, a website is entirely in en-US, the creator of the site has not had the time or does not plan to add i18n for one reason or another. This would make the date/time components the only thing localized on the site.
The developer may not even realize this is occurring and can cause formatting issues if they don't test/design the UI in a suitable manner for each locale.
So with that in mind, for now, I'm going to close this issue. Should you wish to localize them in your app, you can do so by using Navigator.language or another means and setting it in a global context that you can apply to each component.
In the future, we may consider adding a LocaleProvider of sorts that each of these components will attempt to reach into to grab the locale, but this will be a 1.x feature rather than 1.0 as I need to do more research on it.
Browsers already provide a localized version of the native <input type="date"> element. Devs should be already familiar with it. And AFAIK you can't turn off that localization.
Why should en-US be used as the default? Why not an ISO8601 standard like yyyy-mm-dd ?
The developer may not even realize this is occurring and can cause formatting issues if they don't test/design the UI in a suitable manner for each locale.
But their en-US would be broken for non US users trying out their site and see dates "out of order". Most sites are in english but expect international audiences.
Describe the feature in detail (code, mocks, or screenshots encouraged)
Consider defaulting the
locale
of the various caldendar/date components to the user's preferred locale instead ofen
.What type of pull request would this be?
None
Provide relevant links or additional information.
Relevant MDN API docs:
Note: I haven't tested these APIs, how they work with different browser UI language and OS language etc.
On a last note, theoritically the user could have this setup too: OS based on
en-us
but dates and numbers formatting set to a european format egel-GR
. I am not sure if there is a way to detect this setup.The text was updated successfully, but these errors were encountered: