Skip to content

fix(content-docs): use category key for generated-index translation lookup#11743

Merged
slorber merged 5 commits intofacebook:mainfrom
4RH1T3CT0R7:fix/issue-11738-translation-key-generated-index
Feb 19, 2026
Merged

fix(content-docs): use category key for generated-index translation lookup#11743
slorber merged 5 commits intofacebook:mainfrom
4RH1T3CT0R7:fix/issue-11738-translation-key-generated-index

Conversation

@4RH1T3CT0R7
Copy link
Copy Markdown
Contributor

@4RH1T3CT0R7 4RH1T3CT0R7 commented Feb 14, 2026

Motivation

Fixes #11738

When a sidebar category has a custom key attribute (via _category_.json or sidebar config), the translation system has two phases:

  1. Write phase (getSidebarTranslationFileContent): generates translation keys using category.key ?? category.label
  2. Read phase (translateSidebar - transformSidebarCategoryLink): looks up translations to apply them

The read phase for generated-index title and description was using category.label instead of category.key ?? category.label, so when a category had a custom key, the lookup key didn't match the written key and translations silently failed.

This was already correctly handled for category labels, link labels, and doc labels - only the generated-index title/description lookups were broken.

Changes

translations.ts (2-line fix):

  • Extract const categoryKey = category.key ?? category.label in transformSidebarCategoryLink
  • Use categoryKey instead of category.label in the two generated-index translation key lookups

translations.test.ts:

  • Added a category with custom key and generated-index link to the existing conflict test fixture
  • Updated inline snapshots accordingly
  • Added a dedicated round-trip test verifying that translateLoadedContent correctly applies translations when a category has both key and a generated-index link

Test plan

  • yarn jest packages/docusaurus-plugin-content-docs/src/__tests__/translations.test.ts - all 6 tests pass
  • Existing snapshot tests unchanged (backwards-compatible when key is undefined)
  • yarn build:packages

…ookup

When a sidebar category has a custom `key` attribute, the translation
system generates keys using `category.key ?? category.label`. However,
the read phase (`transformSidebarCategoryLink`) was using
`category.label` directly for generated-index title and description
lookups, causing a key mismatch and silent translation failure.

This aligns the generated-index lookup with the existing pattern
already used for category labels, link labels, and doc labels.

Fixes facebook#11738
@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Feb 14, 2026

Hi @4RH1T3CT0R7!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@netlify
Copy link
Copy Markdown

netlify bot commented Feb 14, 2026

[V2]

Name Link
🔨 Latest commit 41df686
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/69971621d9e5cb0007d8af52
😎 Deploy Preview https://deploy-preview-11743--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 project configuration.

@meta-cla meta-cla bot added the CLA Signed Signed Facebook CLA label Feb 14, 2026
Copy link
Copy Markdown
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 thanks 👍

Just simplified a bit the test to match what we already had before

@slorber slorber merged commit a8881ad into facebook:main Feb 19, 2026
44 of 45 checks passed
@4RH1T3CT0R7 4RH1T3CT0R7 deleted the fix/issue-11738-translation-key-generated-index branch February 19, 2026 14:42
@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Mar 20, 2026
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.

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

2 participants