Skip to content

[core] Add LocalizationProvider#4620

Merged
bharatkashyap merged 13 commits intomui:masterfrom
bharatkashyap:feat/i18n
Feb 12, 2025
Merged

[core] Add LocalizationProvider#4620
bharatkashyap merged 13 commits intomui:masterfrom
bharatkashyap:feat/i18n

Conversation

@bharatkashyap
Copy link
Collaborator

@bharatkashyap bharatkashyap commented Jan 20, 2025

Breaking Change

@bharatkashyap bharatkashyap added type: new feature Expand the scope of the product to solve a new problem. 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
Collaborator 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

localeText?: Partial<AccountLocaleText>;
}

const defaultAccountLocaleText: Pick<LocaleText, keyof AccountLocaleText> = {
Copy link
Collaborator 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
@bharatkashyap bharatkashyap mentioned this pull request Feb 27, 2025
@gil-obradors gil-obradors mentioned this pull request Mar 17, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

l10n Localization. type: new feature Expand the scope of the product to solve a new problem.

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