[core] Add LocalizationProvider#4620
Conversation
Netlify deploy preview |
| @@ -1,5 +1,5 @@ | |||
| import * as React from 'react'; | |||
| import { AuthenticationContext, SessionContext } from '@toolpad/core/AppProvider'; | |||
| import { AppProvider } from '@toolpad/core/AppProvider'; | |||
There was a problem hiding this comment.
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> = { |
There was a problem hiding this comment.
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
| palette: { | ||
| primary: { main: '#1976d2' }, | ||
| }, | ||
| }, |
There was a problem hiding this comment.
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 }" |
| /** | ||
| * Locale text for components | ||
| */ | ||
| localeText: PropTypes.shape({ |
Breaking Change
Rename some existing localization keys on the
Accountcomponent to make them part of the globalLocaleTextsignInLabel->accountSignInLabelsignOutLabel->accountSignOutLabeliconButtonAriaLabel->accountPreviewIconButtonLabelCloses Enable localization injection from outside for all texts #4565
Closes Allow text change on SignIn button #4673