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(content-docs): allow translating doc labels in sidebars.js #7634

Merged
merged 2 commits into from Jun 16, 2022

Conversation

Josh-Cena
Copy link
Collaborator

@Josh-Cena Josh-Cena commented Jun 16, 2022

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

I noticed that some labels on the Docusaurus website remains untranslated, e.g. https://docusaurus.io/zh-CN/docs/next/i18n/tutorial. I realized this is because these labels are defined in sidebars.js, which we don't extract.

This PR is not the best solution, but requires the least work (otherwise we would need to parse the raw sidebars.js in getTranslationFiles again), so...😅

Test Plan

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

#4542

@Josh-Cena Josh-Cena added the pr: bug fix This PR fixes a bug in a past release. label Jun 16, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 16, 2022
@netlify
Copy link

netlify bot commented Jun 16, 2022

[V2]

Name Link
🔨 Latest commit 3e5d21b
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/62ab210f2bc14200088021fa
😎 Deploy Preview https://deploy-preview-7634--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Jun 16, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 89 🟢 100 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 84 🟢 100 🟢 100 🟢 100 🟢 90 Report

@github-actions
Copy link

github-actions bot commented Jun 16, 2022

Size Change: 0 B

Total Size: 801 kB

ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 52.6 kB
website/build/assets/css/styles.********.css 106 kB
website/build/assets/js/main.********.js 603 kB
website/build/index.html 38.9 kB

compressed-size-action

Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

LGTM 👍 that's what I had in mind

Would just prefer to not have "docLink" in translation key.

.filter((item) => item.translatable);
const docLinksContent: TranslationFileContent = Object.fromEntries(
docs.map((doc) => [
`sidebar.${sidebarName}.docLink.${doc.label!}`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is the key "docLink" instead of just "doc"? I mean, we use "category" and not "categoryLink". It looks better to use the exact same term as the sidebar item type?

Was wondering if we don't want to use different keys for "doc" and "ref"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Was wondering if we don't want to use different keys for "doc" and "ref"?

Not necessarily. A "ref" item is always accompanied by a "doc" item and we probably want to reuse the label for the two items, if they are the same.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmmmm, why not 👍

Someday there will likely someone who will want different translations for different items that share the same label 😅 currently there's potential for conflicts, but this looks like a niche use-case so let's see if anyone complains

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In that case we would need to differentiate each label independently. ref/doc is a pretty arbitrary cutoff, but each label being translated independently is... not too weird, just inconvenient.

@slorber slorber merged commit 20e8e90 into main Jun 16, 2022
@slorber slorber deleted the jc/translate-sidebar branch June 16, 2022 14:11
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.

None yet

3 participants