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
|
slorber
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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
getTranslationFilesagain), so...😅Test Plan
Test links
Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/
Related issues/PRs
#4542