11import { useState , useCallback , useMemo , useEffect } from 'react'
22import { Routes , Route , useParams , useNavigate , Navigate } from 'react-router-dom'
3+ import { useTranslation } from 'react-i18next'
34import { getSteps , defaultConfig } from './wizardData'
45import type { WizardStep , WizardConfig } from './wizardData'
6+ import { translateSteps , useStepTranslationsReady } from './i18n/stepTranslations'
57import { GitHubLogo , ExternalLinkIcon } from './components/Icons'
68import { Landing } from './components/Landing'
79import { SidebarLeft } from './components/SidebarLeft'
810import { SidebarRight } from './components/SidebarRight'
911import { StepContent } from './components/StepContent'
1012import { Tour } from './components/Tour'
13+ import { LanguageSwitcher } from './components/LanguageSwitcher'
1114
1215export default function App ( ) {
1316 const [ checkedItems , setCheckedItems ] = useState < Record < string , boolean > > ( { } )
@@ -90,12 +93,15 @@ function GuidePage({
9093} : GuidePageProps ) {
9194 const { stepId } = useParams < { stepId : string } > ( )
9295 const navigate = useNavigate ( )
96+ const { t, i18n } = useTranslation ( )
97+ const stepsRev = useStepTranslationsReady ( )
9398
9499 const withDataResidency = config . dataResidency
95100
96101 const steps = useMemo (
97- ( ) => getSteps ( config , enterpriseName ) ,
98- [ config , enterpriseName ]
102+ ( ) => translateSteps ( getSteps ( config , enterpriseName ) , enterpriseName ) ,
103+ // eslint-disable-next-line react-hooks/exhaustive-deps
104+ [ config , enterpriseName , i18n . language , stepsRev ]
99105 )
100106
101107 const modePrefix = withDataResidency ? 'dr' : 'standard'
@@ -106,9 +112,9 @@ function GuidePage({
106112
107113 useEffect ( ( ) => {
108114 document . title = step
109- ? `Step ${ currentStep } : ${ step . shortTitle } — EMU Configuration Guide `
110- : 'EMU Configuration Guide'
111- } , [ step , currentStep ] )
115+ ? `${ t ( 'step.stepLabel' , { num : currentStep } ) } : ${ step . shortTitle } — ${ t ( 'header.title' ) } `
116+ : t ( 'header.title' )
117+ } , [ step , currentStep , t ] )
112118
113119 if ( ! step ) {
114120 return < Navigate to = { `/${ modePrefix } /prerequisites` } replace />
@@ -119,6 +125,7 @@ function GuidePage({
119125 const goTo = ( index : number ) => {
120126 if ( index >= 0 && index < steps . length ) {
121127 navigate ( `/${ modePrefix } /${ stripPrefix ( steps [ index ] . id ) } ` )
128+ window . scrollTo ( { top : 0 } )
122129 }
123130 }
124131
@@ -158,9 +165,10 @@ function GuidePage({
158165
159166 < header className = "app-header" >
160167 < GitHubLogo />
161- < h1 > EMU Configuration Guide</ h1 >
162- < button className = "header-tour-btn" onClick = { startTour } title = "Take a guided tour" >
163- 🎯 Tour
168+ < h1 > { t ( 'header.title' ) } </ h1 >
169+ < LanguageSwitcher />
170+ < button className = "header-tour-btn" onClick = { startTour } title = { t ( 'tour.closeTour' ) } >
171+ { t ( 'header.tour' ) }
164172 </ button >
165173 < a
166174 href = { withDataResidency
@@ -171,15 +179,15 @@ function GuidePage({
171179 rel = "noopener noreferrer"
172180 className = "header-link-btn"
173181 >
174- < ExternalLinkIcon /> How to create EMU
182+ < ExternalLinkIcon /> { t ( 'header.howToCreateEmu' ) }
175183 </ a >
176184 < a
177185 href = "https://github.com/account/enterprises/new?users_type=enterprise_managed"
178186 target = "_blank"
179187 rel = "noopener noreferrer"
180188 className = "header-new-enterprise-btn"
181189 >
182- + New Enterprise
190+ { t ( 'header.newEnterprise' ) }
183191 </ a >
184192 < a
185193 href = "https://github.com/congiuluc/github-emu-configuration-guide"
@@ -188,7 +196,7 @@ function GuidePage({
188196 className = "header-repo-btn"
189197 title = "View source on GitHub"
190198 >
191- < GitHubLogo /> Repo
199+ < GitHubLogo /> { t ( 'header.repo' ) }
192200 </ a >
193201 </ header >
194202
0 commit comments