Skip to content

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

Merged
slorber merged 2 commits into
masterfrom
slorber/writeTranslations
Feb 12, 2021
Merged

feat(v2): Add i18n default code translation bundles#4215
slorber merged 2 commits into
masterfrom
slorber/writeTranslations

Conversation

@slorber

@slorber slorber commented Feb 11, 2021

Copy link
Copy Markdown
Collaborator

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

netlify Bot commented Feb 11, 2021

Copy link
Copy Markdown

[V1] Deploy preview success

Built with commit 9c4e7ec

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

@github-actions

github-actions Bot commented Feb 11, 2021

Copy link
Copy Markdown

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

netlify Bot commented Feb 11, 2021

Copy link
Copy Markdown

Deploy preview for docusaurus-2 ready!

Built with commit 9c4e7ec

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

@github-actions

github-actions Bot commented Feb 11, 2021

Copy link
Copy Markdown

⚡️ 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/

@lex111 lex111 left a comment

Copy link
Copy Markdown
Contributor

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

slorber commented Feb 11, 2021

Copy link
Copy Markdown
Collaborator Author

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

lex111 commented Feb 11, 2021

Copy link
Copy Markdown
Contributor

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

@slorber

slorber commented Feb 11, 2021 via email

Copy link
Copy Markdown
Collaborator Author

@lex111 lex111 left a comment

Copy link
Copy Markdown
Contributor

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
@slorber slorber deleted the slorber/writeTranslations branch August 17, 2021 17:59
mrizwanashiq pushed a commit to mrizwanashiq/docusaurus that referenced this pull request Jun 25, 2026
* Add default code translation bundles

* fix tests
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