diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 16e92a2..f2f64bf 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -5,6 +5,7 @@ import type { SectionT } from './Section'; import { Button, ButtonGroup, Truncate } from '@primer/react'; import { ArrowLeftIcon, ArrowRightIcon, ArrowUpIcon } from '@primer/octicons-react' import ScrollButton from './ScrollButton'; +import { withTranslation } from 'react-i18next'; type Props = { t?: any; @@ -37,24 +38,6 @@ function Footer({ t }: Props) { nextSection = sections[0]; prevSection = sections[sections.length-1]; } - - // localize the navigation buttons - let prevButtonText = "Previous Chapter"; - let nextButtonText = "Next Chapter"; - let homeButtonText = "Return to Start"; - if (locale === 'de') { - prevButtonText = "Vorheriges Kapitel"; - nextButtonText = "Nächstes Kapitel"; - homeButtonText = "Zurück zum Start"; - } else if (locale === 'fr') { - prevButtonText = "Chapitre Précédent"; - nextButtonText = "Chapitre Suivant"; - homeButtonText = "Retour au Début"; - } else if (locale === 'it') { - prevButtonText = "Capitolo Precedente"; - nextButtonText = "Prossimo Capitolo"; - homeButtonText = "Ritorno all' Inizio"; - } var prevSlug = prevSection && prevSection.slug; var nextSlug = nextSection && nextSection.slug; @@ -73,12 +56,12 @@ function Footer({ t }: Props) { leadingIcon={prevSection? ArrowLeftIcon: ArrowUpIcon} > {prevSection && - <>{prevButtonText}
+ <>{t('footer.prevButtonText')}
{prevSection?.title} } {!prevSection && - <>{homeButtonText}
  + <>{t('footer.homeButtonText')}
  } @@ -102,7 +85,7 @@ function Footer({ t }: Props) { onClick={() => navigate(`/${prevSlug}`)} leadingIcon={ArrowUpIcon} > - {homeButtonText} + {t('footer.homeButtonText')} } @@ -113,4 +96,4 @@ function Footer({ t }: Props) { } -export default Footer +export default withTranslation()(Footer) diff --git a/src/i18n/de.json b/src/i18n/de.json index cdeefd7..cb5d5f2 100644 --- a/src/i18n/de.json +++ b/src/i18n/de.json @@ -21,6 +21,11 @@ }, "scrollButton": { "tooltip": "Nach Oben Scrollen" + }, + "footer": { + "prevButtonText": "Vorheriges Kapitel", + "nextButtonText": "Nächstes Kapitel", + "homeButtonText": "Zurück zum Start" } } } diff --git a/src/i18n/en.json b/src/i18n/en.json index 42f305b..5498f92 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -21,6 +21,11 @@ }, "scrollButton": { "tooltip": "Scroll to Top" + }, + "footer": { + "prevButtonText": "Previous Chapter", + "nextButtonText": "Next Chapter", + "homeButtonText": "Return to Start" } } } diff --git a/src/i18n/fr.json b/src/i18n/fr.json index ae50c0e..ea84321 100644 --- a/src/i18n/fr.json +++ b/src/i18n/fr.json @@ -21,6 +21,11 @@ }, "scrollButton": { "tooltip": "Remonter en Haut" + }, + "footer": { + "prevButtonText": "Chapitre Précédent", + "nextButtonText": "Chapitre Suivant", + "homeButtonText": "Retour au Début" } } } diff --git a/src/i18n/it.json b/src/i18n/it.json index 2f37b3d..7b63dfc 100644 --- a/src/i18n/it.json +++ b/src/i18n/it.json @@ -21,6 +21,11 @@ }, "scrollButton": { "tooltip": "Scorrere Verso l'Alto" + }, + "footer": { + "prevButtonText": "Capitolo Precedente", + "nextButtonText": "Prossimo Capitolo", + "homeButtonText": "Ritorno all' Inizio" } } }