Skip to content

[code-infra] Embed translations in the @mui/docs package#41246

Merged
Janpot merged 8 commits intomui:masterfrom
Janpot:embed-translations
Feb 27, 2024
Merged

[code-infra] Embed translations in the @mui/docs package#41246
Janpot merged 8 commits intomui:masterfrom
Janpot:embed-translations

Conversation

@Janpot
Copy link
Member

@Janpot Janpot commented Feb 23, 2024

require.context may not exist where this is being used.

@Janpot Janpot added the scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). label Feb 23, 2024
@mui-bot
Copy link

mui-bot commented Feb 23, 2024

Netlify deploy preview

https://deploy-preview-41246--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against b35450c

@Janpot Janpot marked this pull request as ready for review February 23, 2024 15:04
@Janpot Janpot requested a review from michaldudak February 23, 2024 15:04
@michaldudak
Copy link
Member

It seems to me that these translations are Core-specific. The JSON file is created based on the Core directory structure (at least partially), so how do you see sharing this file between repos?

(although this may not be the most burning problem as we don't have translations enabled anywhere AFAIK)

@Janpot
Copy link
Member Author

Janpot commented Feb 26, 2024

As far as I can see only core repo is using this translation file. X/Toolpad seem to be hardcoding the titles in en only. But I agree it's not ideal.

I'll see if I can create a context that we can use to supply custom strings that code-infra relies on, but that are consumer specific, e.g. like those page titles. We can then keep embedding the other strings for common UI like the header.

@Janpot
Copy link
Member Author

Janpot commented Feb 27, 2024

@michaldudak I've split the pages property off of the translations file and embedded the rest in the docs package. The pages part is injected in the DocsProvider through getInitialProps in _app.js. In the i18n module I'm merging all strings together and make them available in a context. WDYT?

Copy link
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@michaldudak michaldudak mentioned this pull request Feb 27, 2024
1 task
@Janpot Janpot merged commit 8bdcff4 into mui:master Feb 27, 2024
mnajdova pushed a commit to mnajdova/material-ui that referenced this pull request Mar 8, 2024
@michaldudak
Copy link
Member

@Janpot, I noticed an issue while trying to use the package - the translations.json file is not included in the build output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants