fix(content-docs): translate generated index pagination title
Pre-flight checklist
- [x] I have read the Contributing Guidelines on pull requests.
- [ ] If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
- [x] If this is a new API or substantial change: the PR has an accompanying issue (closes #8118) and the maintainers have approved on my working plan.
Motivation
This is the same kind of fix as https://github.com/facebook/docusaurus/pull/7634 β deferring the generation of some metadata until contentLoaded.
Test Plan
We don't have tests for i18n + metadata generation, but I did test locally:
Previous:
Current:
Test links
Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/
Related issues/PRs
@slorber I'm not sure if this qualifies as a breaking change since we removed some metadata returned from loadContent. But we should not anticipate piggy-backing the plugin as an intended use case, should we?
[V2]
| Name | Link |
|---|---|
| Latest commit | 80fe374f74365de6e17dbdcd387b6463388b6821 |
| Latest deploy log | https://app.netlify.com/sites/docusaurus-2/deploys/6358d9f53e50080008ad47ec |
| Deploy Preview | https://deploy-preview-8123--docusaurus-2.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
β‘οΈ Lighthouse report for the deploy preview of this PR
| URL | Performance | Accessibility | Best Practices | SEO | PWA | Report |
|---|---|---|---|---|---|---|
| / | π 62 | π’ 97 | π’ 100 | π’ 100 | π’ 90 | Report |
| /docs/installation | π 73 | π’ 100 | π’ 100 | π’ 100 | π’ 90 | Report |
Size Change: 0 B
Total Size: 819 kB
βΉοΈ View Unchanged
| Filename | Size |
|---|---|
website/.docusaurus/globalData.json |
52.6 kB |
website/build/assets/css/styles.********.css |
112 kB |
website/build/assets/js/main.********.js |
614 kB |
website/build/index.html |
40.8 kB |
So what I understand is that we should add the navigation metadata to the docs only after having translated the sidebars (ie the category index titles).
What annoys be me a bit is that I wish the contentLoaded() was receiving data in an already "processed" shape where the data structure can immediately be used to construct routes and everything. IE make it easy for users to implement their own contentLoaded.
Maybe we need an extra processContent lifecycle for that? loadContent => translate => process > contentLoaded: does it make sense? IMHO we can delay this decision after having a first-class API to extend plugins.
Note: is this expected that the sidebar became untranslated? I'm assuming your local test didn't include downloading all the translated MD and you just translated the category index title locally?

@slorber I'm not sure if this qualifies as a breaking change since we removed some metadata returned from loadContent. But we should not anticipate piggy-backing the plugin as an intended use case, should we?
To me removing data from a lifecycle is a breaking change. But I wouldn't consider it a breaking change only if we added new data.
At the same time we don't officially provide an official public API to override contentLoaded so only users doing the temporary workaround suggested in https://github.com/facebook/docusaurus/issues/4138 would likely be affected by it. That may include some plugin authors.
I think we can mark it as a breaking change. It is a minor i18n bugfix that can wait 3.0 IMHO and it's not really worth it to backport it immediately.
I guess you didn't update the snapshots for now to help the review, can you make the PR pass?
Also, we had the navigation snapshotted before, is there a good way to still prevent possible navigation regressions with our current test setup?
There are other tests failing because this has changed the loaded content. I will fix that later. And yesβI only hand-wrote the translation that needed to be written.
is there a good way to still prevent possible navigation regressions with our current test setup?
This is the reason I haven't fixed the tests yet. I think we can only snapshot the generated data instead.
OK! I think I've finally got the tests figured out.
Maybe not yetπ Such a pain
I'm also experiencing a situation where the title translation is not working, is there a temporary solution?
any progress about this π
+1
Would much appreciate if we can take another look at this issue. This is esp. bad if EN is not the default locale.
We're encountering the same issue, and as @yujingz it feels really weird for users as the primary language of website is not EN. Any news on it? And what could be done to help if required?
Hi, we are experiencing the same issue with the generated index not being fully translated. Any plan to correct this shortly ? Is it possible to help in a way or another ?