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

[pickers] Stop using utils in locales #14505

Merged

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Sep 5, 2024

Fixes #13768

I need to avoid 2 type of breaking changes

  1. For the people overriding the locale (they must still receive value and utils)
  2. For the people overriding a component that calls this translation (the built-in locale must still work even if they don't pass formattedDate yet)

So I'm handling both the old and the new format in each locale.
This is not clean code, but we can clean it easily during the alpha and the end result will be even better than before this PR.

New DX

In v7

const translations = useTranslations();
// TS will complain since we are not passing the utils, but it will work with any built-in locale
const label = translations.openTimePickerDialogue(value, {} as any, value == null ? null : value.format('MM/DD/YYY'));

In v8

const translations = useTranslations();
// TS will complain since we are not passing the utils, but it will work with any built-in locale
const label = translations.openTimePickerDialogue(value == null ? null : value.format('MM/DD/YYY'));

Follow up

  • In v8 alpha: Remove value and utils params from openDatePickerDialogue, openTimePickerDialogue and clockLabelText

@flaviendelangle flaviendelangle self-assigned this Sep 5, 2024
@flaviendelangle flaviendelangle added component: pickers This is the name of the generic UI component, not the React module! customization: extend Logic customizability labels Sep 5, 2024
@mui-bot
Copy link

mui-bot commented Sep 5, 2024

Localization writing tips ✍️

Seems you are updating localization 🌍 files.

Thank you for contributing to the localization! 🎉 To make your PR perfect, here is a list of elements to check: ✔️

  • Verify if the PR title respects the release format. Here are two examples (depending if you update or add a locale file)

    [l10n] Improve Swedish (sv-SE) locale
    [l10n] Add Danish (da-DK) locale

  • Update the documentation of supported locales by running pnpm l10n
  • Clean files with pnpm prettier.

Deploy preview: https://deploy-preview-14505--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 87b392e

@flaviendelangle flaviendelangle force-pushed the stop-using-utils-in-locale branch 2 times, most recently from 6d4b7ff to 6c5ee15 Compare September 5, 2024 15:23
@flaviendelangle flaviendelangle marked this pull request as ready for review September 6, 2024 06:38
Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking care of it! 🙏
The DX looks great. 👍
We are going to clean this up nicely on 8. 👌

Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 🚀 💯

@flaviendelangle flaviendelangle merged commit bf71a58 into mui:master Sep 6, 2024
18 checks passed
@flaviendelangle flaviendelangle deleted the stop-using-utils-in-locale branch September 6, 2024 11:29
arthurbalduini pushed a commit to arthurbalduini/mui-x that referenced this pull request Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! customization: extend Logic customizability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pickers] How can I get access to the Pickers Adapter Utils for use with usePickersTranslations?
4 participants