Skip to content

Commit 301605d

Browse files
committed
Added localization
1 parent 2359b9b commit 301605d

23 files changed

Lines changed: 10725 additions & 197 deletions

package-lock.json

Lines changed: 98 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
"vite": "^8.0.0"
1818
},
1919
"dependencies": {
20+
"i18next": "^26.0.3",
2021
"react": "^19.2.4",
2122
"react-dom": "^19.2.4",
23+
"react-i18next": "^17.0.2",
2224
"react-router-dom": "^7.13.1"
2325
}
2426
}

public/favicon.svg

Lines changed: 2 additions & 13 deletions
Loading

src/App.tsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { useState, useCallback, useMemo, useEffect } from 'react'
22
import { Routes, Route, useParams, useNavigate, Navigate } from 'react-router-dom'
3+
import { useTranslation } from 'react-i18next'
34
import { getSteps, defaultConfig } from './wizardData'
45
import type { WizardStep, WizardConfig } from './wizardData'
6+
import { translateSteps, useStepTranslationsReady } from './i18n/stepTranslations'
57
import { GitHubLogo, ExternalLinkIcon } from './components/Icons'
68
import { Landing } from './components/Landing'
79
import { SidebarLeft } from './components/SidebarLeft'
810
import { SidebarRight } from './components/SidebarRight'
911
import { StepContent } from './components/StepContent'
1012
import { Tour } from './components/Tour'
13+
import { LanguageSwitcher } from './components/LanguageSwitcher'
1114

1215
export 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

src/components/CopyableUrl.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { useState } from 'react'
2+
import { useTranslation } from 'react-i18next'
23
import { CopyIcon } from './Icons'
34

45
export function CopyableUrl({ url }: { url: string }) {
56
const [copied, setCopied] = useState(false)
7+
const { t } = useTranslation()
68
const handleCopy = () => {
79
navigator.clipboard.writeText(url).then(() => {
810
setCopied(true)
@@ -12,7 +14,7 @@ export function CopyableUrl({ url }: { url: string }) {
1214
return (
1315
<span className="copyable-url">
1416
<code>{url}</code>
15-
<button onClick={handleCopy} className="copy-btn" title="Copy to clipboard">
17+
<button onClick={handleCopy} className="copy-btn" title={t('common.copyToClipboard')}>
1618
{copied ? '✓' : <CopyIcon />}
1719
</button>
1820
</span>

0 commit comments

Comments
 (0)