Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ exports[`getTranslationFiles returns translation files matching snapshot 1`] = `
"description": "Navbar item with label Dropdown item 2",
"message": "Dropdown item 2",
},
"logo.alt": {
"description": "The alt of navbar logo",
"message": "Navbar alt Logo",
},
"title": {
"description": "The title in the navbar",
"message": "navbar title",
Expand Down Expand Up @@ -49,6 +53,10 @@ exports[`getTranslationFiles returns translation files matching snapshot 1`] = `
"description": "The title of the footer links column with title=Footer link column 2 in the footer",
"message": "Footer link column 2",
},
"logo.alt": {
"description": "The alt of footer logo",
"message": "Footer alt Logo",
},
},
"path": "footer",
},
Expand All @@ -71,6 +79,10 @@ exports[`getTranslationFiles returns translation files matching snapshot 2`] = `
"description": "Navbar item with label Dropdown item 2",
"message": "Dropdown item 2",
},
"logo.alt": {
"description": "The alt of navbar logo",
"message": "Navbar alt Logo",
},
"title": {
"description": "The title in the navbar",
"message": "navbar title",
Expand All @@ -92,6 +104,10 @@ exports[`getTranslationFiles returns translation files matching snapshot 2`] = `
"description": "The label of footer link with label=Link 2 linking to https://facebook.com",
"message": "Link 2",
},
"logo.alt": {
"description": "The alt of footer logo",
"message": "Footer alt Logo",
},
},
"path": "footer",
},
Expand Down Expand Up @@ -131,6 +147,10 @@ exports[`translateThemeConfig returns translated themeConfig 1`] = `
"title": "Footer link column 2 (translated)",
},
],
"logo": {
"alt": "Footer alt Logo",
"src": "/img/test_logo.svg",
},
"style": "light",
},
"navbar": {
Expand All @@ -150,6 +170,10 @@ exports[`translateThemeConfig returns translated themeConfig 1`] = `
"label": "Dropdown (translated)",
},
],
"logo": {
"alt": "Navbar alt Logo",
"src": "/img/test_logo.svg",
},
"style": "dark",
"title": "navbar title (translated)",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const ThemeConfigSample = {
},
navbar: {
title: 'navbar title',
logo: {
alt: 'Navbar alt Logo',
src: '/img/test_logo.svg',
},
style: 'dark',
hideOnScroll: false,
items: [
Expand All @@ -31,6 +35,10 @@ const ThemeConfigSample = {
],
},
footer: {
logo: {
alt: 'Footer alt Logo',
src: '/img/test_logo.svg',
},
copyright: 'Copyright FB',
style: 'light',
links: [
Expand All @@ -52,6 +60,10 @@ const ThemeConfigSample = {
const ThemeConfigSampleSimpleFooter: ThemeConfig = {
...ThemeConfigSample,
footer: {
logo: {
alt: 'Footer alt Logo',
src: '/img/test_logo.svg',
},
copyright: 'Copyright FB',
style: 'light',
links: [
Expand Down
31 changes: 29 additions & 2 deletions packages/docusaurus-theme-classic/src/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,20 @@ function getNavbarTranslationFile(navbar: Navbar): TranslationFileContent {
? {title: {message: navbar.title, description: 'The title in the navbar'}}
: {};

return mergeTranslations([titleTranslations, navbarItemsTranslations]);
const logoAlt: TranslationFileContent = navbar.logo?.alt
? {
'logo.alt': {
message: navbar.logo?.alt,
description: 'The alt of navbar logo',
},
}
: {};

return mergeTranslations([
titleTranslations,
logoAlt,
navbarItemsTranslations,
]);
}
function translateNavbar(
navbar: Navbar,
Expand Down Expand Up @@ -119,7 +132,21 @@ function getFooterTranslationFile(footer: Footer): TranslationFileContent {
}
: {};

return mergeTranslations([footerLinkTitles, footerLinkLabels, copyright]);
const logoAlt: TranslationFileContent = footer.logo?.alt
? {
'logo.alt': {
message: footer.logo?.alt,
description: 'The alt of footer logo',
},
}
: {};

return mergeTranslations([
footerLinkTitles,
footerLinkLabels,
copyright,
logoAlt,
]);
}
function translateFooter(
footer: Footer,
Expand Down