Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default {
verbose: true,
// Default 5s timeout often fails on Windows :s,
// see https://github.com/facebook/docusaurus/pull/8259
testTimeout: 15000,
testTimeout: 25000,
setupFiles: ['./jest/setup.ts'],
testEnvironmentOptions: {
url: 'https://docusaurus.io/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ exports[`getLoadedContentTranslationFiles returns translation files 1`] = `
"description": "The label for link 'Link label' in sidebar 'docs', linking to 'https://facebook.com'",
"message": "Link label",
},
"sidebar.otherSidebar.category.cat-with-key": {
"description": "The label for category 'Category with key' in sidebar 'otherSidebar'",
"message": "Category with key",
},
"sidebar.otherSidebar.category.cat-with-key.link.generated-index.description": {
"description": "The generated-index page description for category 'Category with key' in sidebar 'otherSidebar'",
"message": "Category with key - index description",
},
"sidebar.otherSidebar.category.cat-with-key.link.generated-index.title": {
"description": "The generated-index page title for category 'Category with key' in sidebar 'otherSidebar'",
"message": "Category with key - index title",
},
"sidebar.otherSidebar.doc.Fifth doc translatable": {
"description": "The label for the doc item 'Fifth doc translatable' in sidebar 'otherSidebar', linking to the doc doc5",
"message": "Fifth doc translatable",
Expand Down Expand Up @@ -57,6 +69,18 @@ exports[`getLoadedContentTranslationFiles returns translation files 1`] = `
"description": "The label for link 'Link label' in sidebar 'docs', linking to 'https://facebook.com'",
"message": "Link label",
},
"sidebar.otherSidebar.category.cat-with-key": {
"description": "The label for category 'Category with key' in sidebar 'otherSidebar'",
"message": "Category with key",
},
"sidebar.otherSidebar.category.cat-with-key.link.generated-index.description": {
"description": "The generated-index page description for category 'Category with key' in sidebar 'otherSidebar'",
"message": "Category with key - index description",
},
"sidebar.otherSidebar.category.cat-with-key.link.generated-index.title": {
"description": "The generated-index page title for category 'Category with key' in sidebar 'otherSidebar'",
"message": "Category with key - index title",
},
"sidebar.otherSidebar.doc.Fifth doc translatable": {
"description": "The label for the doc item 'Fifth doc translatable' in sidebar 'otherSidebar', linking to the doc doc5",
"message": "Fifth doc translatable",
Expand Down Expand Up @@ -90,6 +114,18 @@ exports[`getLoadedContentTranslationFiles returns translation files 1`] = `
"description": "The label for link 'Link label' in sidebar 'docs', linking to 'https://facebook.com'",
"message": "Link label",
},
"sidebar.otherSidebar.category.cat-with-key": {
"description": "The label for category 'Category with key' in sidebar 'otherSidebar'",
"message": "Category with key",
},
"sidebar.otherSidebar.category.cat-with-key.link.generated-index.description": {
"description": "The generated-index page description for category 'Category with key' in sidebar 'otherSidebar'",
"message": "Category with key - index description",
},
"sidebar.otherSidebar.category.cat-with-key.link.generated-index.title": {
"description": "The generated-index page title for category 'Category with key' in sidebar 'otherSidebar'",
"message": "Category with key - index title",
},
"sidebar.otherSidebar.doc.Fifth doc translatable": {
"description": "The label for the doc item 'Fifth doc translatable' in sidebar 'otherSidebar', linking to the doc doc5",
"message": "Fifth doc translatable",
Expand Down Expand Up @@ -273,6 +309,21 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
"translatable": true,
"type": "ref",
},
{
"collapsed": false,
"collapsible": true,
"items": [],
"key": "cat-with-key",
"label": "Category with key (translated)",
"link": {
"description": "Category with key - index description (translated)",
"permalink": "/docs/category/cat-with-key",
"slug": "/category/cat-with-key-slug",
"title": "Category with key - index title (translated)",
"type": "generated-index",
},
"type": "category",
},
],
},
"tagsPath": "/tags/",
Expand Down Expand Up @@ -444,6 +495,21 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
"translatable": true,
"type": "ref",
},
{
"collapsed": false,
"collapsible": true,
"items": [],
"key": "cat-with-key",
"label": "Category with key (translated)",
"link": {
"description": "Category with key - index description (translated)",
"permalink": "/docs/category/cat-with-key",
"slug": "/category/cat-with-key-slug",
"title": "Category with key - index title (translated)",
"type": "generated-index",
},
"type": "category",
},
],
},
"tagsPath": "/tags/",
Expand Down Expand Up @@ -615,6 +681,21 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
"translatable": true,
"type": "ref",
},
{
"collapsed": false,
"collapsible": true,
"items": [],
"key": "cat-with-key",
"label": "Category with key (translated)",
"link": {
"description": "Category with key - index description (translated)",
"permalink": "/docs/category/cat-with-key",
"slug": "/category/cat-with-key-slug",
"title": "Category with key - index title (translated)",
"type": "generated-index",
},
"type": "category",
},
],
},
"tagsPath": "/tags/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ function createSampleVersion(
label: 'Fifth doc translatable',
translatable: true,
},
{
type: 'category',
key: 'cat-with-key',
label: 'Category with key',
collapsed: false,
collapsible: true,
link: {
type: 'generated-index',
slug: '/category/cat-with-key-slug',
permalink: '/docs/category/cat-with-key',
title: 'Category with key - index title',
description: 'Category with key - index description',
},
items: [],
},
],
},
...version,
Expand Down
5 changes: 3 additions & 2 deletions packages/docusaurus-plugin-content-docs/src/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,14 @@ function translateSidebar({
return undefined;
}
if (category.link.type === 'generated-index') {
const categoryKey = category.key ?? category.label;
const title =
sidebarsTranslations[
`sidebar.${sidebarName}.category.${category.label}.link.generated-index.title`
`sidebar.${sidebarName}.category.${categoryKey}.link.generated-index.title`
]?.message ?? category.link.title;
const description =
sidebarsTranslations[
`sidebar.${sidebarName}.category.${category.label}.link.generated-index.description`
`sidebar.${sidebarName}.category.${categoryKey}.link.generated-index.description`
]?.message ?? category.link.description;
return {
...category.link,
Expand Down
Loading