From 83080f0d25887b3f92e5e9bce6cc6a591f9c6d22 Mon Sep 17 00:00:00 2001 From: Matiboux Date: Sat, 18 Oct 2025 01:21:14 +0200 Subject: [PATCH 1/6] Add LocalesPicker component --- .../LocalesPicker/LocalesPicker.astro | 47 +++++++++++++++++++ .../LocalesPicker/LocalesPicker.spec.ts | 26 ++++++++++ 2 files changed, 73 insertions(+) create mode 100644 app/app/src/components/LocalesPicker/LocalesPicker.astro create mode 100644 app/app/src/components/LocalesPicker/LocalesPicker.spec.ts diff --git a/app/app/src/components/LocalesPicker/LocalesPicker.astro b/app/app/src/components/LocalesPicker/LocalesPicker.astro new file mode 100644 index 0000000..0ba0a62 --- /dev/null +++ b/app/app/src/components/LocalesPicker/LocalesPicker.astro @@ -0,0 +1,47 @@ +--- +export interface Props +{ + lang?: string | undefined +} + +const { + lang = Astro.currentLocale, +} = Astro.props +--- + + + + diff --git a/app/app/src/components/LocalesPicker/LocalesPicker.spec.ts b/app/app/src/components/LocalesPicker/LocalesPicker.spec.ts new file mode 100644 index 0000000..7d6c4a1 --- /dev/null +++ b/app/app/src/components/LocalesPicker/LocalesPicker.spec.ts @@ -0,0 +1,26 @@ +import { experimental_AstroContainer as AstroContainer } from 'astro/container' +import { expect, test } from 'vitest' +import LocalesPicker from './LocalesPicker.astro' + +test('LocalesPicker with defaults', async () => +{ + const container = await AstroContainer.create() + const result = await container.renderToString(LocalesPicker) + + expect(result).toBeTruthy() + expect(result).not.toContain('active') +}) + +test('LocalesPicker with FR language', async () => +{ + const container = await AstroContainer.create() + const result = await container.renderToString(LocalesPicker, { + props: { + lang: 'fr', + } + }) + + expect(result).toBeTruthy() + expect(result).toContain('active') + expect(result).toMatch(/]+class="active"[^>]*>/) +}) From 65fbebdeb84cb41936c3bc5c25e544fdfc28d9a4 Mon Sep 17 00:00:00 2001 From: Matiboux Date: Sat, 18 Oct 2025 01:21:42 +0200 Subject: [PATCH 2/6] Use LocalesPicker component --- app/app/src/pages/index.astro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/app/src/pages/index.astro b/app/app/src/pages/index.astro index 6eea7b7..03b3049 100644 --- a/app/app/src/pages/index.astro +++ b/app/app/src/pages/index.astro @@ -1,5 +1,6 @@ --- import { getCollection } from 'astro:content' +import LocalesPicker from '~/components/LocalesPicker/LocalesPicker.astro' import Layout from '~/layouts/Layout.astro' import logosrc from '~/assets/logo.png?url' @@ -37,6 +38,8 @@ function getTitleFromBody(body: string | undefined): string | undefined
+ +

{_({ From 8deaef5c6edf93153fa9b8906dc1b33e56e9832b Mon Sep 17 00:00:00 2001 From: Matiboux Date: Sat, 18 Oct 2025 01:24:19 +0200 Subject: [PATCH 3/6] fix default locale in LocalesPicker --- app/app/src/components/LocalesPicker/LocalesPicker.astro | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/app/src/components/LocalesPicker/LocalesPicker.astro b/app/app/src/components/LocalesPicker/LocalesPicker.astro index 0ba0a62..cdf10ad 100644 --- a/app/app/src/components/LocalesPicker/LocalesPicker.astro +++ b/app/app/src/components/LocalesPicker/LocalesPicker.astro @@ -11,13 +11,13 @@ const {

From 65c7e80d6c963e86a880a0ff18afb159dd58623c Mon Sep 17 00:00:00 2001 From: Matiboux Date: Sat, 18 Oct 2025 01:33:57 +0200 Subject: [PATCH 4/6] Add todo --- app/app/src/components/LocalesPicker/LocalesPicker.astro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/app/src/components/LocalesPicker/LocalesPicker.astro b/app/app/src/components/LocalesPicker/LocalesPicker.astro index cdf10ad..8155583 100644 --- a/app/app/src/components/LocalesPicker/LocalesPicker.astro +++ b/app/app/src/components/LocalesPicker/LocalesPicker.astro @@ -7,6 +7,9 @@ export interface Props const { lang = Astro.currentLocale, } = Astro.props + +// TODO: Get the path for the current page to link to the same page in other locales +// do that in static rendering mode ---
    From df9e4287d3372c70b99f58118f44daac994e5275 Mon Sep 17 00:00:00 2001 From: Matiboux Date: Sun, 19 Oct 2025 21:20:29 +0200 Subject: [PATCH 5/6] Remove proxy page for index --- app/app/src/pages/en/index.astro | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 app/app/src/pages/en/index.astro diff --git a/app/app/src/pages/en/index.astro b/app/app/src/pages/en/index.astro deleted file mode 100644 index 25090d8..0000000 --- a/app/app/src/pages/en/index.astro +++ /dev/null @@ -1,5 +0,0 @@ ---- -import Page from '~/pages/index.astro' ---- - - From 4247135616723bb2ff322d0c649830722808d333 Mon Sep 17 00:00:00 2001 From: Matiboux Date: Sun, 19 Oct 2025 21:20:39 +0200 Subject: [PATCH 6/6] Update links in LocalesPicker --- .../components/LocalesPicker/LocalesPicker.astro | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/app/src/components/LocalesPicker/LocalesPicker.astro b/app/app/src/components/LocalesPicker/LocalesPicker.astro index 8155583..1177de3 100644 --- a/app/app/src/components/LocalesPicker/LocalesPicker.astro +++ b/app/app/src/components/LocalesPicker/LocalesPicker.astro @@ -1,4 +1,6 @@ --- +import { getRelativeLocaleUrl } from 'astro:i18n' + export interface Props { lang?: string | undefined @@ -7,19 +9,22 @@ export interface Props const { lang = Astro.currentLocale, } = Astro.props - -// TODO: Get the path for the current page to link to the same page in other locales -// do that in static rendering mode ---