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

Wrong logic on write-translation.js #710

Merged
merged 1 commit into from
May 30, 2018
Merged

Conversation

gimdongwoo
Copy link
Contributor

@gimdongwoo gimdongwoo commented May 30, 2018

Motivation

I found wrong logic on lib/write-translation.js

const path = require('path');
...
if (fs.existsSync(path)) {  // wrong code. `path` is NodeJs module
  currentTranslations = JSON.parse(
    fs.readFileSync(CWD + '/i18n/en.json', 'utf8')
  );
}

As a result, currentTranslations is always empty.
Because, the contents of i18n/en.json are always lost.

It's correct code

if (fs.existsSync(CWD + '/i18n/en.json')) {
  currentTranslations = JSON.parse(
    fs.readFileSync(CWD + '/i18n/en.json', 'utf8')
  );
}

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Related PRs

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 30, 2018
@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-preview ready!

Built with commit bf80b33

https://deploy-preview-710--docusaurus-preview.netlify.com

Copy link
Contributor

@yangshun yangshun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch. Thanks!

@yangshun yangshun merged commit 49a5263 into facebook:master May 30, 2018
@JoelMarcey
Copy link
Contributor

We have had that piece of code since October 2017. Makes me wonder how translations actually have worked at all 😆 🤣

@endiliey
Copy link
Contributor

endiliey commented Jun 2, 2018

Before this PR is merged, It always generate new i18en.json and is not allowing us to override english string from what #158 intend to do. currentTranslation is always lost

Actually this introduces bug #713

@JoelMarcey
Copy link
Contributor

@endiliey Are you saying this fix introduces #713? Or that without this fix, #713 exists?

@endiliey
Copy link
Contributor

endiliey commented Jun 2, 2018

without this fix #713 doesnt exist
With this fix introduces #713

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants