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

Enable localization injection from outside for all texts #4565

Closed
fredicious opened this issue Dec 28, 2024 · 6 comments · Fixed by #4620
Closed

Enable localization injection from outside for all texts #4565

fredicious opened this issue Dec 28, 2024 · 6 comments · Fixed by #4620
Assignees
Labels
enhancement This is not a bug, nor a new feature good first issue Great for first contributions. Enable to learn the contribution process. scope: toolpad-core Abbreviated to "core"

Comments

@fredicious
Copy link

fredicious commented Dec 28, 2024

Summary

It would be nice to avoid hard-coded English texts, and allow localization.

Examples

example of hard-coded English text: https://github.com/mui/toolpad/blob/master/packages/toolpad-core/src/SignInPage/SignInPage.tsx#L349

Motivation

I am building a dashboard in another language.

Search keywords: localize, translate, lang

@fredicious fredicious added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 28, 2024
@bharatkashyap bharatkashyap added enhancement This is not a bug, nor a new feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 30, 2024
@bharatkashyap
Copy link
Member

bharatkashyap commented Dec 30, 2024

Agreed. A LocaleContext already exists internally and is consumed by the Account and related components: https://mui.com/toolpad/core/react-account/#labels

We can extend the LocaleContextType to include every label across components, and add an optional defaultLocaleText prop on the AppProvider and consume the LocaleContext inside the AppProvider instead of Account.

@bharatkashyap bharatkashyap added the good first issue Great for first contributions. Enable to learn the contribution process. label Dec 30, 2024
@Janpot
Copy link
Member

Janpot commented Jan 6, 2025

We can model it after the X implementation. See https://mui.com/x/react-date-pickers/localization/

@fredicious Which languages did you have in mind and are you open to contribute translations for them?

@gil-obradors
Copy link
Contributor

As it is a first case, if no one else starts working on it, I would take care of it myself, but in two weeks' time.
@Janpot Regardless of who starts the work, once done I can contribute with Spanish and Catalan.

@Janpot Janpot moved this from Planned to Backlog in MUI Toolpad public roadmap Jan 13, 2025
@Alexandre-Voinier-Afleya

I'm interested by this feature, I can contribute with French.

Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@fredicious How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

@gil-obradors
Copy link
Contributor

Hi @bharatkashyap,
I have already done the translations of ca and es
I need to create a index.ts inside locales folder, otherwise it won't export my locales neither commited hiIn localization

My locales folder:

  • ca|en|es|hiIn.tsx
  • getLocalization.ts
  • index.ts

My index.ts file:

export { default as ca } from "./ca"
export { default as es } from "./es"
export { default as en } from "./en"
export { default as hiIN} from './hiIN'

In Spanish

Image

Catalan:

Image

Is index.ts the correct way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is not a bug, nor a new feature good first issue Great for first contributions. Enable to learn the contribution process. scope: toolpad-core Abbreviated to "core"
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

6 participants