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

[l10n] Allow importing the direct locale file #10920

Open
LukasTy opened this issue Nov 6, 2023 · 2 comments
Open

[l10n] Allow importing the direct locale file #10920

LukasTy opened this issue Nov 6, 2023 · 2 comments
Labels
core Infrastructure work going on behind the scenes l10n localization

Comments

@LukasTy
Copy link
Member

LukasTy commented Nov 6, 2023

Localization files are a perfect candidate for importing directly (2 levels deep in our case).
The majority of date libraries suggest doing it like this as well, i.e.:

  • import 'dayjs/locale/fr';
  • import 'moment/locale/fr;

In our case, the following is not possible: import { frFR } from '@mui/x-date-pickers/locales/frFR';.

Allowing the deeper import would:

  • avoid the dev performance drawback of bundling all the locales.
  • make the localization more in line with the approach used by date libraries
  • potentially avoid the need to artificially limit the amount of locales we want to support (bundle)

Related issues: #10918, #10919, mui/material-ui#39525.

Search keywords:

@LukasTy LukasTy added core Infrastructure work going on behind the scenes l10n localization labels Nov 6, 2023
@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 6, 2023

Would it work with only?

import { frFR } from '@mui/x-date-pickers/locale-frFR';

Supporting 3rd levels import comes with a downside. Today, we set the expectation that all 2nd level imports are allowed and all 3rd levels are not. Introduction an exception to the rule could make it hard for developers to know when which one is OK.

Related to mui/material-ui#31096.

@LukasTy
Copy link
Member Author

LukasTy commented Nov 7, 2023

Would it work with only?

It would, but what about localization-related DX?
I think many people might already be used to localization usually being imported directly, however, your suggestion seems quite an unusual one. 🤔

Just confirming, that @flaviendelangle was specifically suggesting to introduce such importing exception only for locales, with a plan of possibly removing the locales/index and re-exporting on the next major, thus avoiding any problems with bundle bulking. 🤔
WDYT @oliviertassinari about such a plan?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes l10n localization
Projects
None yet
Development

No branches or pull requests

2 participants