Skip to content

fix(docs): generated-index link translations use category.label instead of category.key for lookup #11738

@akshatsinha0

Description

@akshatsinha0

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

  1. Create a sidebar category with a custom key attribute in _category_.json
  2. Give that category a generated-index link with a title and description
  3. Run docusaurus write-translations to generate the translation file
  4. Translate the generated-index title and description entries in the translation file
  5. 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

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its execution

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions