Have you read the Contributing Guidelines on issues?
Prerequisites
Description
getSidebarTranslationFileContent in packages/docusaurus-plugin-content-docs/src/translations.ts
generates translation keys for category generated-index links using category.key ?? category.label
(lines 96, 109, 118).
But transformSidebarCategoryLink in the same file looks up those translations using only
category.label (lines 182, 186), ignoring the key attribute entirely.
Line 200 in the same translateSidebar function already correctly uses item.key ?? item.label for
category label lookups. Same for links (line 210) and docs (line 219). Only
transformSidebarCategoryLink was missed.
Related: #8118
Reproducible demo
No response
Steps to reproduce
- Create a sidebar category with a custom
key attribute in _category_.json
- Give that category a
generated-index link with a title and description
- Run
docusaurus write-translations to generate the translation file
- Translate the generated-index title and description entries in the translation file
- Build the site with the target locale
Expected behavior
The generated-index page title and description resolve from the translation file using the key sidebar <name>.category.<key>.link.generated-index.title.
Actual behavior
The generated-index page title and description remain untranslated because transformSidebarCategoryLink looks up sidebar.<name>.category.<label>.link.generated-index.title while the translation file contains sidebar.<name>.category.<key>.link.generated-index.title.
Your environment
- Public source code:
- Public site URL:
- Docusaurus version used:
- Environment name and version (e.g. Chrome 89, Node.js 16.4):
- Operating system and version (e.g. Ubuntu 20.04.2 LTS):
Self-service
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clearoryarn clearcommand.rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages.Description
getSidebarTranslationFileContentinpackages/docusaurus-plugin-content-docs/src/translations.tsgenerates translation keys for category generated-index links using
category.key ?? category.label(lines 96, 109, 118).
But
transformSidebarCategoryLinkin the same file looks up those translations using onlycategory.label(lines 182, 186), ignoring thekeyattribute entirely.Line 200 in the same
translateSidebarfunction already correctly usesitem.key ?? item.labelforcategory label lookups. Same for links (line 210) and docs (line 219). Only
transformSidebarCategoryLinkwas missed.Related: #8118
Reproducible demo
No response
Steps to reproduce
keyattribute in_category_.jsongenerated-indexlink with a title and descriptiondocusaurus write-translationsto generate the translation fileExpected behavior
The generated-index page title and description resolve from the translation file using the key
sidebar <name>.category.<key>.link.generated-index.title.Actual behavior
The generated-index page title and description remain untranslated because
transformSidebarCategoryLinklooks upsidebar.<name>.category.<label>.link.generated-index.titlewhile the translation file containssidebar.<name>.category.<key>.link.generated-index.title.Your environment
Self-service