Skip to content

[charts] Add a localization provider #17325

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Apr 11, 2025

Fix #16963

This introduces the localisation for charts. It will be more useful when we introduce the toolbar since buttons and helpers will need some text.

For info, the data grid put its locales in its apiRef and the pickers in a dedicated context.

I went with the picker approach because we have a similar issue: defining the locale once and using it in multiple components and their subcomponent.

Having a dedicated provider allows targeting it in the MUI theme's defaultProps.

@alexfauquette alexfauquette added the component: charts This is the name of the generic UI component, not the React module! label Apr 11, 2025
Copy link

github-actions bot commented Apr 11, 2025

Thanks for adding a type label to the PR! 👍

Copy link

Please add one type label to categorize the purpose of this PR appropriately:

docs, release, bug, regression, maintenance, dependencies, enhancement or new feature

@alexfauquette alexfauquette added the enhancement This is not a bug, nor a new feature label Apr 11, 2025
@mui-bot
Copy link

mui-bot commented Apr 11, 2025

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
  • Verify that you have added an export line in src/locales/index.ts for the new locale.
  • Run pnpm docs:api which should add your new translation to the list of exported interfaces.
  • Clean files with pnpm prettier.

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

Updated pages:

Generated by 🚫 dangerJS against 5b76242

Copy link

codspeed-hq bot commented Apr 11, 2025

CodSpeed Performance Report

Merging #17325 will not alter performance

Comparing alexfauquette:add-localization (5b76242) with master (edec2bd)

Summary

✅ 8 untouched benchmarks

Copy link
Member

Choose a reason for hiding this comment

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

Should this be called ChartsLocalizationTableNoSnap? It seems like we're using enUS spelling

Comment on lines +2 to +6
import LocalisationTable from 'docsx/src/modules/components/LocalizationTable';
import data from './data.json';

export default function ChartsLocalizationTableNoSnap() {
return <LocalisationTable data={data} />;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import LocalisationTable from 'docsx/src/modules/components/LocalizationTable';
import data from './data.json';
export default function ChartsLocalizationTableNoSnap() {
return <LocalisationTable data={data} />;
import LocalizationTable from 'docsx/src/modules/components/LocalizationTable';
import data from './data.json';
export default function ChartsLocalizationTableNoSnap() {
return <LocalizationTable data={data} />;

export interface ChartsLocalizationProviderProps {
children?: React.ReactNode;
/**
* Locale for charts components texts.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Locale for charts components texts.
* Localized text for chart components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: charts This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[charts] Pie chart loading text not localizable
3 participants