Skip to content

Commit 53e2508

Browse files
authored
feat(web): i18n FR/EN du site — routing /[locale], landing et blog bilingues (#54) (#55)
- Routing : app/[locale]/(default) avec generateStaticParams en/fr ; middleware de négociation (cookie locale persistant + Accept-Language), / redirige vers la locale ; header x-locale pour <html lang> côté root layout (typed routes Next 16 : pas de params au root layout) - Dictionnaires par section messages/{en,fr}/<section>.ts — la parité des clés est garantie par le compilateur (fr fait satisfies typeof en) - Chrome traduit : header, mobile menu, footer, sélecteur FR/EN (liens, cookie persistant par le middleware, sync de <html lang> en navigation client) - Landing : hero, quickstart, features, features-02, playground, demos, changelog, cta — 100 % des chaînes via dictionnaires (EN source, FR traduit) - Blog : index + slug + premier-agent-cartpole — metadata localisées, dates formatées selon la locale, liens /{locale}/blog - Sections traduites non rendues sur la landing d'origine (clients, story, demoCatalog, pricing, customers, team) : dictionnaires prêts, structure de la page inchangée - Docs nextra non localisées (V1) ; contenu MDX des articles non traduit Vérifié : next build vert (121 pages), tsc --noEmit 0 erreur, pnpm test 416 passés (baseline main inchangée), navigateur headless : /en et /fr 200, bascule instantanée, cookie persistant, / → /fr avec Accept-Language fr, <html lang> correct, blog FR rendu.
1 parent 761e0f7 commit 53e2508

69 files changed

Lines changed: 1311 additions & 372 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎packages/web/app/(default)/blog/page.tsx‎

Lines changed: 0 additions & 35 deletions
This file was deleted.

‎packages/web/app/(default)/layout.tsx‎

Lines changed: 0 additions & 39 deletions
This file was deleted.

‎packages/web/app/(default)/page.tsx‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

packages/web/app/(default)/blog/[slug]/page.tsx renamed to packages/web/app/[locale]/(default)/blog/[slug]/page.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import { notFound } from 'next/navigation'
33
import { MDXRemote } from 'next-mdx-remote-client/rsc'
44
import rehypePrettyCode from 'rehype-pretty-code'
55
import { blogArticles, findBlogArticle, readBlogArticle } from '@/lib/blog'
6+
import { getDictionary } from '@/lib/i18n'
7+
import { isLocale, type Locale } from '@/lib/locales'
68

7-
type ArticleParams = { params: Promise<{ slug: string }> }
9+
type ArticleParams = { params: Promise<{ slug: string; locale: string }> }
810

911
export function generateStaticParams() {
1012
return blogArticles.filter(article => article.environment !== 'cartpole').map(({ slug }) => ({ slug }))
@@ -23,14 +25,17 @@ export async function generateMetadata({ params }: ArticleParams) {
2325
}
2426

2527
export default async function EnvironmentArticlePage({ params }: ArticleParams) {
26-
const article = findBlogArticle((await params).slug)
28+
const { slug, locale: raw } = await params
29+
const locale: Locale = isLocale(raw) ? raw : 'en'
30+
const t = getDictionary(locale)
31+
const article = findBlogArticle(slug)
2732
if (!article) notFound()
28-
const date = new Date(`${article.date}T12:00:00Z`).toLocaleDateString('fr-FR', { day: 'numeric', month: 'long', year: 'numeric', timeZone: 'Europe/Paris' })
33+
const date = new Date(`${article.date}T12:00:00Z`).toLocaleDateString(locale === 'fr' ? 'fr-FR' : 'en-US', { day: 'numeric', month: 'long', year: 'numeric', timeZone: 'Europe/Paris' })
2934
return (
30-
<article lang="fr" className="max-w-4xl mx-auto px-4 sm:px-6 pt-32 md:pt-40 pb-24">
35+
<article lang={locale} className="max-w-4xl mx-auto px-4 sm:px-6 pt-32 md:pt-40 pb-24">
3136
<header className="mb-12">
32-
<Link href="/blog" className="text-indigo-400 hover:text-indigo-300">← Le blog Ignition</Link>
33-
<p className="text-sm text-slate-400 mt-8 mb-3"><time dateTime={article.date}>{date}</time> · Tutoriel</p>
37+
<Link href={`/${locale}/blog`} className="text-indigo-400 hover:text-indigo-300">{t.blog.backToBlog}</Link>
38+
<p className="text-sm text-slate-400 mt-8 mb-3"><time dateTime={article.date}>{date}</time> · {t.blog.tutorialLabel}</p>
3439
<h1 className="h1 mb-6">{article.title}</h1>
3540
<p className="text-xl text-slate-300">{article.description}</p>
3641
</header>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import Image from 'next/image'
2+
import Link from 'next/link'
3+
import type { Metadata } from 'next'
4+
import { blogArticles } from '@/lib/blog'
5+
import { getDictionary } from '@/lib/i18n'
6+
import { isLocale, type Locale } from '@/lib/locales'
7+
8+
type BlogParams = { params: Promise<{ locale: string }> }
9+
10+
export async function generateMetadata({ params }: BlogParams): Promise<Metadata> {
11+
const { locale: raw } = await params
12+
const locale: Locale = isLocale(raw) ? raw : 'en'
13+
const t = getDictionary(locale)
14+
return { title: t.blog.metadata.title, description: t.blog.metadata.description }
15+
}
16+
17+
export default async function BlogPage({ params }: BlogParams) {
18+
const { locale: raw } = await params
19+
const locale: Locale = isLocale(raw) ? raw : 'en'
20+
const t = getDictionary(locale)
21+
22+
return (
23+
<section lang={locale} className="max-w-4xl mx-auto px-4 sm:px-6 pt-32 md:pt-40 pb-24">
24+
<p className="text-indigo-400 mb-3">{t.blog.kicker}</p>
25+
<h1 className="h1 mb-4">{t.blog.heading}</h1>
26+
<p className="text-lg text-slate-400 mb-12">{t.blog.subheading}</p>
27+
<div className="grid gap-8 md:grid-cols-2">
28+
{blogArticles.map(article => (
29+
<article key={article.slug} className="rounded-xl border border-slate-700 overflow-hidden bg-slate-800/30">
30+
<Link href={`/${locale}/blog/${article.slug}`} className="block group">
31+
<Image src={article.image} alt={article.imageAlt} width={1920} height={1080} className="w-full h-auto" />
32+
<div className="p-6 sm:p-8">
33+
<time dateTime={article.date} className="text-sm text-slate-400">
34+
{new Date(`${article.date}T12:00:00Z`).toLocaleDateString(locale === 'fr' ? 'fr-FR' : 'en-US', { day: 'numeric', month: 'long', year: 'numeric', timeZone: 'Europe/Paris' })} · {t.blog.tutorialLabel}
35+
</time>
36+
<h2 className="text-2xl font-semibold mt-3 mb-3 group-hover:text-indigo-300">{article.title}</h2>
37+
<p className="text-slate-300">{article.description}</p>
38+
<p className="text-indigo-400 mt-5">{t.blog.readMore}</p>
39+
</div>
40+
</Link>
41+
</article>
42+
))}
43+
</div>
44+
</section>
45+
)
46+
}

packages/web/app/(default)/blog/premier-agent-cartpole/page.tsx renamed to packages/web/app/[locale]/(default)/blog/premier-agent-cartpole/page.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import Link from 'next/link'
22
import { MDXRemote } from 'next-mdx-remote-client/rsc'
33
import rehypePrettyCode from 'rehype-pretty-code'
44
import { cartpoleArticle, readCartpoleArticle } from '@/lib/blog'
5+
import { getDictionary } from '@/lib/i18n'
6+
import { isLocale, type Locale } from '@/lib/locales'
57

68
export const metadata = {
79
title: cartpoleArticle.title,
@@ -15,14 +17,18 @@ export const metadata = {
1517
},
1618
}
1719

18-
export default function CartpoleArticlePage() {
20+
export default async function CartpoleArticlePage({ params }: { params: Promise<{ locale: string }> }) {
21+
const { locale: raw } = await params
22+
const locale: Locale = isLocale(raw) ? raw : 'en'
23+
const t = getDictionary(locale)
24+
const date = new Date(`${cartpoleArticle.date}T12:00:00Z`).toLocaleDateString(locale === 'fr' ? 'fr-FR' : 'en-US', { day: 'numeric', month: 'long', year: 'numeric', timeZone: 'Europe/Paris' })
1925
return (
20-
<article lang="fr" className="max-w-4xl mx-auto px-4 sm:px-6 pt-32 md:pt-40 pb-24">
26+
<article lang={locale} className="max-w-4xl mx-auto px-4 sm:px-6 pt-32 md:pt-40 pb-24">
2127
<header className="mb-12">
22-
<Link href="/blog" className="text-indigo-400 hover:text-indigo-300">← Le blog Ignition</Link>
23-
<p className="text-sm text-slate-400 mt-8 mb-3"><time dateTime={cartpoleArticle.date}>3 octobre 2026</time> · Tutoriel</p>
28+
<Link href={`/${locale}/blog`} className="text-indigo-400 hover:text-indigo-300">{t.blog.backToBlog}</Link>
29+
<p className="text-sm text-slate-400 mt-8 mb-3"><time dateTime={cartpoleArticle.date}>{date}</time> · {t.blog.tutorialLabel}</p>
2430
<h1 className="h1 mb-6">{cartpoleArticle.title}</h1>
25-
<p className="text-xl text-slate-300">Lancez l’expérience dans votre navigateur, puis découvrez le code qui la fait tourner.</p>
31+
<p className="text-xl text-slate-300">{t.blog.cartpoleIntro}</p>
2632
</header>
2733
<div className="prose prose-invert prose-lg max-w-none prose-headings:text-slate-100 prose-a:text-indigo-300 prose-pre:overflow-x-auto prose-pre:bg-slate-950 prose-img:rounded-xl prose-img:border prose-img:border-slate-700">
2834
<MDXRemote source={readCartpoleArticle()} options={{ mdxOptions: { rehypePlugins: [[rehypePrettyCode, { theme: 'one-dark-pro' }]] } }} />

packages/web/app/(default)/changelog/page.tsx renamed to packages/web/app/[locale]/(default)/changelog/page.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import Link from 'next/link'
22
import { getChangelog } from '@/lib/changelog'
3+
import { getDictionary } from '@/lib/i18n'
4+
import { isLocale } from '@/lib/locales'
35

46
export const metadata = {
57
title: 'Changelog',
68
description: 'Release notes and shipped features for IgnitionAI.',
79
}
810

9-
export default function ChangelogPage() {
11+
export default async function ChangelogPage({ params }: { params: Promise<{ locale: string }> }) {
12+
const { locale } = await params
13+
const t = getDictionary(isLocale(locale) ? locale : 'en').changelog.page
1014
const releases = getChangelog()
1115

1216
return (
@@ -16,29 +20,29 @@ export default function ChangelogPage() {
1620
{/* Header */}
1721
<div className="pb-10 md:pb-14 text-center">
1822
<div className="inline-flex font-medium bg-clip-text text-transparent bg-linear-to-r from-indigo-500 to-indigo-200 pb-3">
19-
Changelog
23+
{t.eyebrow}
2024
</div>
2125
<h1 className="h1 bg-clip-text text-transparent bg-linear-to-r from-slate-200/60 via-slate-200 to-slate-200/60 pb-4">
22-
What we've shipped
26+
{t.title}
2327
</h1>
2428
<p className="text-lg text-slate-400">
25-
Every release, with its full list of changes. Source of truth is{' '}
29+
{t.descriptionBefore}
2630
<a
2731
href="https://github.com/IgnitionAI/ignition/blob/main/CHANGELOG.md"
2832
target="_blank"
2933
rel="noopener noreferrer"
3034
className="text-indigo-400 hover:text-indigo-300 underline"
3135
>
32-
CHANGELOG.md on GitHub
36+
{t.sourceLink}
3337
</a>
34-
.
38+
{t.descriptionAfter}
3539
</p>
3640
</div>
3741

3842
{/* Releases */}
3943
<div className="space-y-12 pb-24">
4044
{releases.map((release) => {
41-
const prettyDate = new Date(release.date).toLocaleDateString('en-US', {
45+
const prettyDate = new Date(release.date).toLocaleDateString(locale === 'fr' ? 'fr-FR' : 'en-US', {
4246
year: 'numeric',
4347
month: 'long',
4448
day: 'numeric',
@@ -81,7 +85,7 @@ export default function ChangelogPage() {
8185
{/* Back to landing */}
8286
<div className="text-center pb-16">
8387
<Link href="/" className="text-indigo-400 hover:text-indigo-300 text-sm">
84-
← Back to IgnitionAI
88+
{t.backLink}
8589
</Link>
8690
</div>
8791

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { getDictionary } from '@/lib/i18n'
2+
import { isLocale, type Locale } from '@/lib/locales'
3+
import AosInit from '@/components/ui/aos-init'
4+
import Header from '@/components/ui/header'
5+
import Footer from '@/components/ui/footer'
6+
7+
export function generateStaticParams(): { locale: string }[] {
8+
return [{ locale: 'en' }, { locale: 'fr' }]
9+
}
10+
11+
export default async function DefaultLayout({
12+
children,
13+
params,
14+
}: {
15+
children: React.ReactNode
16+
params: Promise<{ locale: string }>
17+
}) {
18+
const { locale: raw } = await params
19+
const locale: Locale = isLocale(raw) ? raw : 'en'
20+
const t = getDictionary(locale)
21+
22+
return (
23+
<>
24+
<AosInit />
25+
<Header t={t.nav} locale={locale} />
26+
27+
<main className="grow">
28+
{children}
29+
</main>
30+
31+
<Footer t={t.footer} locale={locale} />
32+
</>
33+
)
34+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
export const metadata = {
2+
title: 'IgnitionAI — Train RL agents in your browser',
3+
description: 'The ML-Agents of the JavaScript creative ecosystem. Train reinforcement learning agents directly in the browser, deploy anywhere via ONNX.',
4+
}
5+
6+
import Hero from '@/components/hero'
7+
import QuickStart from '@/components/quickstart'
8+
import Features from '@/components/features'
9+
import Features02 from '@/components/features-02'
10+
import Playground from '@/components/playground'
11+
import Demos from '@/components/demos'
12+
import Cta from '@/components/cta'
13+
import Changelog from '@/components/changelog'
14+
import { getDictionary } from '@/lib/i18n'
15+
import { isLocale } from '@/lib/locales'
16+
17+
export default async function Home({ params }: { params: Promise<{ locale: string }> }) {
18+
const { locale } = await params
19+
const t = getDictionary(isLocale(locale) ? locale : 'en')
20+
21+
// Structure identique à la landing d'origine — les autres sections traduites
22+
// (clients, story, demoCatalog, pricing, customers, team) restent disponibles
23+
// dans les dictionnaires pour une future utilisation.
24+
return (
25+
<>
26+
<Hero t={t.hero} />
27+
<QuickStart t={t.quickstart} />
28+
<Features t={t.features} />
29+
<Features02 t={t.features02} />
30+
<Playground t={t.playground} />
31+
<Demos t={t.demos} />
32+
<Changelog t={t.changelog.section} />
33+
<Cta t={t.cta} />
34+
</>
35+
)
36+
}

‎packages/web/app/layout.tsx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import './css/style.css'
22

3+
import { headers } from 'next/headers'
34
import { Inter } from 'next/font/google'
45

6+
import { isLocale } from '@/lib/locales'
7+
58
const inter = Inter({
69
subsets: ['latin'],
710
variable: '--font-inter',
@@ -17,13 +20,17 @@ export const metadata = {
1720
'The ML-Agents of the JavaScript creative ecosystem. Train reinforcement learning agents directly in the browser. Deploy anywhere via ONNX.',
1821
}
1922

20-
export default function RootLayout({
23+
export default async function RootLayout({
2124
children,
2225
}: {
2326
children: React.ReactNode
2427
}) {
28+
// La locale voyage en header (injectée par middleware) — le root layout
29+
// ne reçoit pas de params sous Next 16 (typed routes).
30+
const locale = (await headers()).get('x-locale') ?? 'en'
31+
2532
return (
26-
<html lang="en" dir="ltr" suppressHydrationWarning className="scroll-smooth">
33+
<html lang={isLocale(locale) ? locale : 'en'} dir="ltr" suppressHydrationWarning className="scroll-smooth">
2734
<body className={`${inter.variable} font-inter antialiased bg-slate-900 text-slate-100 tracking-tight`}>
2835
<div className="flex flex-col min-h-screen overflow-hidden supports-[overflow:clip]:overflow-clip">
2936
{children}

0 commit comments

Comments
 (0)