-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
Conversation
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site settings. |
7b694a5
to
b46434b
Compare
⚡️ Lighthouse report for the deploy preview of this PR
|
Size Change: 0 B Total Size: 801 kB ℹ️ View Unchanged
|
There was a problem hiding this 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!}`, |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Pre-flight checklist
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