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

[core] Add LocalizationProvider #4620

Merged
merged 13 commits into from
Feb 12, 2025
Merged

Conversation

bharatkashyap
Copy link
Member

@bharatkashyap bharatkashyap commented Jan 20, 2025

Breaking Change

@bharatkashyap bharatkashyap added new feature New feature or request l10n localization labels Jan 20, 2025
@mui-bot
Copy link

mui-bot commented Jan 20, 2025

Netlify deploy preview

https://deploy-preview-4620--mui-toolpad-docs.netlify.app/

Generated by 🚫 dangerJS against 9a68c44

@@ -1,5 +1,5 @@
import * as React from 'react';
import { AuthenticationContext, SessionContext } from '@toolpad/core/AppProvider';
import { AppProvider } from '@toolpad/core/AppProvider';
Copy link
Member Author

@bharatkashyap bharatkashyap Jan 23, 2025

Choose a reason for hiding this comment

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

This change on all demos is because none of the demos on this page were using the Account component inside the AppProvider. I changed them to do this, since I think that is expected use. It also allows us to demonstrate overriding global localization using the localeText prop.

Kept one example which still demonstrates using Account without AppProvider but the individual context providers instead

}

const defaultAccountLocaleText: Pick<LocaleText, keyof AccountLocaleText> = {
Copy link
Member Author

@bharatkashyap bharatkashyap Jan 23, 2025

Choose a reason for hiding this comment

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

Using component-level defaults as a worst-case default for standalone usage of the component without any context being provided, similar to Material UI practice

@bharatkashyap bharatkashyap requested a review from Janpot January 23, 2025 09:12
palette: {
primary: { main: '#1976d2' },
},
},
Copy link
Member

Choose a reason for hiding this comment

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

Should we add core locale as well? That would be the user's intent, likely, rigth?

"localeText": {
"type": {
"name": "shape",
"description": "{ accountPreviewIconButtonLabel?: string, accountPreviewTitle?: string, accountSignInLabel?: string, accountSignOutLabel?: string, alert?: string, cancel?: string, close?: string, confirm?: string, delete?: string, email?: string, loading?: string, magicLinkSignInTitle?: string, oauthSignInTitle?: string, ok?: string, or?: string, passkey?: string, passkeySignInTitle?: string, password?: string, save?: string, signInRememberMe?: string, signInSubtitle?: string, signInTitle?: string, to?: string, username?: string, with?: string }"
Copy link
Member

Choose a reason for hiding this comment

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

This won't scale. Any way we can do the same as X?

/**
* Locale text for components
*/
localeText: PropTypes.shape({
Copy link
Member

Choose a reason for hiding this comment

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

Same scaling issue here

@bharatkashyap bharatkashyap requested a review from Janpot February 12, 2025 10:39
Copy link
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

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

👍

@bharatkashyap bharatkashyap merged commit ea0e2c6 into mui:master Feb 12, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
l10n localization new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow text change on SignIn button Enable localization injection from outside for all texts
3 participants