-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
feat(theme): add ability to translate navbar+footer logo alt text #8616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
08b63ea
4abadd7
4b2a657
2c04eac
9f66723
9e8c12e
b629694
c44511d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 text of navbar logo', | ||
| }, | ||
| } | ||
| : {}; | ||
|
|
||
| return mergeTranslations([ | ||
| titleTranslations, | ||
| logoAlt, | ||
| navbarItemsTranslations, | ||
| ]); | ||
| } | ||
| function translateNavbar( | ||
| navbar: Navbar, | ||
|
|
@@ -54,9 +67,17 @@ function translateNavbar( | |
| if (!navbarTranslations) { | ||
| return navbar; | ||
| } | ||
|
|
||
| const {logo} = navbar; | ||
|
|
||
| if (logo) { | ||
| logo.alt = navbarTranslations[`logo.alt`]?.message ?? navbar.logo?.alt; | ||
| } | ||
|
||
|
|
||
| return { | ||
| ...navbar, | ||
| title: navbarTranslations.title?.message ?? navbar.title, | ||
| logo, | ||
| // TODO handle properly all the navbar item types here! | ||
| items: navbar.items.map((item) => { | ||
| const subItems = item.items?.map((subItem) => ({ | ||
|
|
@@ -119,7 +140,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 text of footer logo', | ||
| }, | ||
| } | ||
| : {}; | ||
|
|
||
| return mergeTranslations([ | ||
| footerLinkTitles, | ||
| footerLinkLabels, | ||
| copyright, | ||
| logoAlt, | ||
| ]); | ||
| } | ||
| function translateFooter( | ||
| footer: Footer, | ||
|
|
@@ -149,10 +184,17 @@ function translateFooter( | |
|
|
||
| const copyright = footerTranslations.copyright?.message ?? footer.copyright; | ||
|
|
||
| const {logo} = footer; | ||
|
|
||
| if (logo) { | ||
| logo.alt = footerTranslations[`logo.alt`]?.message ?? footer.logo?.alt; | ||
| } | ||
|
|
||
| return { | ||
| ...footer, | ||
| links, | ||
| copyright, | ||
| logo, | ||
| }; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.