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

fix(v2): i18n translation extractor should handle JSX formatting edge cases better #3920

Merged

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Dec 14, 2020

Motivation

Jest has this JSX content that would not be extracted properly by the i18n translation extractor:

          <Translate>
            {`Find out what's new with Jest.
- Follow[Jest](https://twitter.com/fbjest) on Twitter.
- Subscribe to the[Jest blog](/blog/).
- Look at the[changelog](https://github.com/facebook/jest/blob/master/CHANGELOG.md).`}
          </Translate>

This is become Babel AST parses this as 3 childrens: [empty text node, JSX expression, empty text node]

In such case we'll filter out the empty text nodes to focus mainly on the important node containing the translations

Have you read the Contributing Guidelines on pull requests?

yes

Test Plan

unit tests

…pty text nodes around the content to translate
@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Dec 14, 2020
@slorber slorber requested a review from lex111 as a code owner December 14, 2020 18:26
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Dec 14, 2020
@netlify
Copy link

netlify bot commented Dec 14, 2020

✔️ Deploy preview for docusaurus-2 ready!

🔨 Explore the source changes: 4bbd4e2

🔍 Inspect the deploy logs: https://app.netlify.com/sites/docusaurus-2/deploys/5fd7af84078a610008fc93a3

😎 Browse the preview: https://deploy-preview-3920--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Dec 14, 2020

Size Change: +19 B (0%)

Total Size: 152 kB

ℹ️ View Unchanged
Filename Size Change
website/build/blog/2017/12/14/introducing-docusaurus/index.html 20.7 kB 0 B
website/build/docs/introduction/index.html 180 B 0 B
website/build/index.html 5.8 kB -1 B
website/build/main.********.js 108 kB +20 B (0%)
website/build/styles.********.css 17.6 kB 0 B

compressed-size-action

@github-actions
Copy link

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 45
🟢 Accessibility 99
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-3920--docusaurus-2.netlify.app/classic/

@slorber slorber merged commit 1db0277 into master Dec 14, 2020
@slorber slorber deleted the slorber/fix-translation-extractor-jsx-formatting-issue branch August 17, 2021 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants