docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

fix(content-docs): translate generated index pagination title

Open Josh-Cena opened this issue 3 years ago β€’ 19 comments

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:

image

Current:

image

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

Josh-Cena avatar Sep 21 '22 21:09 Josh-Cena

@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?

Josh-Cena avatar Sep 21 '22 21:09 Josh-Cena

[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...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Sep 21 '22 21:09 netlify[bot]

⚑️ 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

github-actions[bot] avatar Sep 21 '22 21:09 github-actions[bot]

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

compressed-size-action

github-actions[bot] avatar Sep 21 '22 21:09 github-actions[bot]

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?

CleanShot 2022-09-30 at 15 39 28@2x


@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.

slorber avatar Sep 30 '22 13:09 slorber

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?

slorber avatar Sep 30 '22 13:09 slorber

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.

Josh-Cena avatar Sep 30 '22 14:09 Josh-Cena

OK! I think I've finally got the tests figured out.

Josh-Cena avatar Oct 26 '22 06:10 Josh-Cena

Maybe not yetπŸ˜… Such a pain

Josh-Cena avatar Oct 26 '22 06:10 Josh-Cena

I'm also experiencing a situation where the title translation is not working, is there a temporary solution?

Lorde627 avatar May 28 '23 10:05 Lorde627

any progress about this πŸ‘€

Lorde627 avatar Jan 15 '24 11:01 Lorde627

+1

ikallali avatar Feb 03 '24 11:02 ikallali

Would much appreciate if we can take another look at this issue. This is esp. bad if EN is not the default locale.

yujingz avatar Mar 07 '24 09:03 yujingz

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?

qvignaud avatar Mar 29 '24 10:03 qvignaud

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 ?

ncoroy avatar Apr 08 '24 15:04 ncoroy