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

Calendar/Date components: Default locale to user lang preference #793

Closed
sledgehammer999 opened this issue Oct 21, 2024 · 2 comments
Closed
Labels
enhancement An improvement to an existing feature/component

Comments

@sledgehammer999
Copy link

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 of en.

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 eg el-GR. I am not sure if there is a way to detect this setup.

@sledgehammer999 sledgehammer999 changed the title Calendar/Date components: Default locale to user preference Calendar/Date components: Default locale to user lang preference Oct 21, 2024
@huntabyte huntabyte added the enhancement An improvement to an existing feature/component label Oct 22, 2024
@huntabyte
Copy link
Owner

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.

Thank you!

@huntabyte huntabyte closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2024
@sledgehammer999
Copy link
Author

Just some thoughts to consider.

  1. 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.
  2. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement to an existing feature/component
Projects
None yet
Development

No branches or pull requests

2 participants