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

feat(v2): Add i18n default code translation bundles #4215

Merged
merged 2 commits into from
Feb 12, 2021

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Feb 11, 2021

Motivation

For strings hardcoded in a theme (like "next"/"previous" pagination labels), we can pre-translate them in the current locale so that the user does not have to.

These "provided translation bundles" serve for 2 things:

  • init the files with fallback messages when using docusaurus write-translations --locale fr
  • fallback message values when running docusaurus start --locale fr even if fr/code.json does not exist

Test Plan

Tests

@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Feb 11, 2021
@slorber slorber requested a review from lex111 as a code owner February 11, 2021 16:53
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Feb 11, 2021
@netlify
Copy link

netlify bot commented Feb 11, 2021

[V1] Deploy preview success

Built with commit 9c4e7ec

https://deploy-preview-4215--docusaurus-1.netlify.app

@github-actions
Copy link

github-actions bot commented Feb 11, 2021

Size Change: +14 B (0%)

Total Size: 156 kB

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

compressed-size-action

@netlify
Copy link

netlify bot commented Feb 11, 2021

Deploy preview for docusaurus-2 ready!

Built with commit 9c4e7ec

https://deploy-preview-4215--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Feb 11, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 87
🟢 Accessibility 96
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

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

Copy link
Contributor

@lex111 lex111 left a comment

Choose a reason for hiding this comment

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

Awesome!

Can we do extract messages for translation from attributes like aria-label?
Also can we take into account subthemes like docusaurus-theme-search-algolia (eg it contains input placeholder text "Search").

@slorber
Copy link
Collaborator Author

slorber commented Feb 11, 2021

I'll have to complete all the missing translations and things we can translate, but here it's mostly the infrastructure.

Providing exhaustive aria label translations and other language fallback translations can probably be made in other PRS

@lex111
Copy link
Contributor

lex111 commented Feb 11, 2021

Ah, got it, so if wrap other raw strings in the translation API functions, then they will be accessible to extract?

@slorber
Copy link
Collaborator Author

slorber commented Feb 11, 2021 via email

Copy link
Contributor

@lex111 lex111 left a comment

Choose a reason for hiding this comment

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

Great, thank you! I'll make other raw strings translatable in the next PR.

@slorber slorber merged commit 6a94ad9 into master Feb 12, 2021
@lex111 lex111 added this to the v2.0.0-alpha.71 milestone Mar 1, 2021
This was referenced Mar 10, 2021
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: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants