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

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

Merged
merged 8 commits into from
Feb 27, 2024

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 Specific to the core-infra product 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
22 checks passed
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 Specific to the core-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants