docusaurus: Unable to change docs title
Is this a bug report?
Yes
Have you read the Contributing Guidelines on issues?
Yes
Environment
Platform Agnostic Latest Docusaurus (master branch)
Steps to Reproduce / Reproducible Demo
- Use latest master branch of Docusaurus & install
- Start server
cd website
yarn start
- Go to http://localhost:3000/docs/en/next/installation.html
- Change
docs/getting-started-installation.mdtitle toInstallation asdf
- Stop the server and start it again with
yarn start - Go to http://localhost:3000/docs/en/next/installation.html
Expected Behavior
Actual Behavior
Investigation
This happen after PR #710
Prior to this, i18n/en.json is always newly generated
After this, i18n/en.json will persist and override newly generated i18n/en.json
Hence, title is not changing
But PR #710 is correct because it fixes bug from #158 that allow user allow overriding of english strings
Workaround
Delete i18n/en.json when changing title
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 18 (16 by maintainers)
Commits related to this issue
- [RFC] Move custom translation strings to its own file Fixes #713 — committed to JoelMarcey/Docusaurus by JoelMarcey 6 years ago
What is intended from PR #158 is that user can override Docusaurus provided strings that a project may not like (for example ReasonReact would like to say “Edit” instead of “Edit this Doc” in English). So they can modify
i18en.jsondirectlyRelated code: https://github.com/facebook/Docusaurus/blob/fa20c93d5c1b5a9369cf1c5909955fc58f0dcb8e/lib/write-translations.js#L27-L31
https://github.com/facebook/Docusaurus/blob/fa20c93d5c1b5a9369cf1c5909955fc58f0dcb8e/lib/write-translations.js#L158-L164
But this introduces this bug because if I made a change to my title, old title from
i18en.jsonexist & overridesi18en.jsonnew titleIf we always delete
i18en.jsonthat is just the same as not allowing to override strings and effectively deleting this code: https://github.com/facebook/Docusaurus/blob/fa20c93d5c1b5a9369cf1c5909955fc58f0dcb8e/lib/write-translations.js#L27-L31That’s why there has been no issue with that code before #710 since October 2017
Sounds great @joelmarcey.
Are you going to work on it ? Otherwise, I can submit a PR when I’m back roughly after this week.
@endiliey
I think I kinda like option #2 after giving it some thought today. What we can do is load the generated
i18n/en.jsonfirst and and get that in thecurrentTranslationsarray. Then loadi18n/custom-en.jsonand either override current values in the array if there would be a duplicate or append to the array.What do you think?
I have few alternatives
Delete https://github.com/facebook/Docusaurus/blob/fa20c93d5c1b5a9369cf1c5909955fc58f0dcb8e/lib/write-translations.js#L27-L31
https://github.com/facebook/Docusaurus/blob/fa20c93d5c1b5a9369cf1c5909955fc58f0dcb8e/lib/write-translations.js#L158-L164
custom-en.jsonIf this is the case we might need to un- git ignore
custom-en.json& update the docs