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

[DataGrid] Support ready-to-use locales #777

Closed
oliviertassinari opened this issue Dec 23, 2020 · 5 comments · Fixed by #983 or #1024
Closed

[DataGrid] Support ready-to-use locales #777

oliviertassinari opened this issue Dec 23, 2020 · 5 comments · Fixed by #983 or #1024
Assignees
Labels
component: data grid This is the name of the generic UI component, not the React module! new feature New feature or request
Milestone

Comments

@oliviertassinari
Copy link
Member

We have added the support in #196 for providing custom localization strings. It's also known as internationalization or i18n.
However, we can probably push it one step further. For the components in the main repository, we offer the capability to tap into pre-translated locales: https://material-ui.com/guides/localization/#locale-text. We aim to support the top 100 most used locales.

I think that we should offer the same capability here. There are two steps:

  1. Do the infrastructure work to make this possible. We can aim to add a few locales to seed the effort: French, Spanish, Bulgarian.
  2. Have the community contribute the translations they need.

We might need to replace the current build infrastructure to use the one from the main repository to make it work. I think that we need to support:

import { zhCN } from '@material-ui/data-grid/locale';
import { zhCN } from '@material-ui/x-grid/locale';
import { zhCN } from '@material-ui/x/locale';

or

import zhCN from '@material-ui/data-grid/locale-zhCN';
import zhCN from '@material-ui/x-grid/locale-zhCN';
import zhCN from '@material-ui/x/locale-zhCN';

We need the dev environment, where tree-shaking is disabled, to be fast.

Benchmark

@oliviertassinari oliviertassinari added component: data grid This is the name of the generic UI component, not the React module! new feature New feature or request waiting for 👍 Waiting for upvotes labels Dec 23, 2020
@oliviertassinari oliviertassinari changed the title [DataGrid] Support ready-to-use locale [DataGrid] Support ready-to-use locales Dec 23, 2020
@oliviertassinari oliviertassinari added this to the Sprint 9 milestone Jan 18, 2021
@oliviertassinari oliviertassinari modified the milestones: Sprint 9, Sprint 10 Feb 1, 2021
@oliviertassinari
Copy link
Member Author

oliviertassinari commented Feb 8, 2021

Reopening as we miss #984 to completely solve the issue. A large part of the problem has been solved though.

@oliviertassinari
Copy link
Member Author

oliviertassinari commented Feb 10, 2021

Reopening, I think that we should at the very least document the import to use in https://master--material-ui-x.netlify.app/components/data-grid/localization/#locale-text. This information is currently not obvious to find (has to be inferred from the table and the core docs page).

  • If we want to push it further, we can have a code snippet with the theme. It would duplicate a bit with the main docs, but maybe it's fine.
  • If we want to push it to its extreme, we could have the same demo as https://material-ui.com/guides/localization/#example (import * the locales and render them).

I might also add that developers might/likely don't know how to use data grid and core translations at the same time.

@DanailH
Copy link
Member

DanailH commented Feb 10, 2021

Ok, I added a code snippet that I got from the https://material-ui.com/guides/localization/#example. I made a PR with the change https://github.com/mui-org/material-ui-x/pull/1024/files

@nappalm
Copy link

nappalm commented Apr 13, 2023

@oliviertassinari
What happens with the translation of the Grid Toolbar, I have applied according to the example of Localization but it only works in the pagination

image

@DanailH
Copy link
Member

DanailH commented Apr 13, 2023

Hey @nappalm, just a quick note - if you think there is a bug please open a new issue with a reproduction example so we can take a look. Also, I'm not sure if you check the localization example in the data grid docs: https://mui.com/x/react-data-grid/localization/ it might help as well to solve your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
3 participants