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

  1. Use latest master branch of Docusaurus & install
  2. Start server
cd website
yarn start
  1. Go to http://localhost:3000/docs/en/next/installation.html
  2. Change docs/getting-started-installation.md title to Installation asdf
change
  1. Stop the server and start it again with yarn start
  2. Go to http://localhost:3000/docs/en/next/installation.html

Expected Behavior

title_change

Actual Behavior

title_no_change

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

Most upvoted comments

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.json directly

Related 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.json exist & overrides i18en.json new title

If we always delete i18en.json that 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-L31

That’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.json first and and get that in the currentTranslations array. Then load i18n/custom-en.json and 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

  1. Don’t allow custom strings. This is like 1.1.5

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

  1. Allow custom string but maybe user has to explicitly name it custom-en.json
if (fs.existsSync(CWD + '/i18n/custom-en.json')) {
  currentTranslations = JSON.parse(
    fs.readFileSync(CWD + '/i18n/custom-en.json', 'utf8')
  );
}

If this is the case we might need to un- git ignore custom-en.json & update the docs