From a81ed6f76b2a973945e8960380aaca64343550f8 Mon Sep 17 00:00:00 2001
From: Javaxman
Date: Wed, 22 Apr 2026 22:49:46 +0200
Subject: [PATCH] Aggiunge menu lingua dropdown e base i18n IT/EN/TH.
Introduce routing multilingua con locale tailandese, selettore lingua a tendina con icone bandiera SVG e gestione chiusura click-outside/Esc, oltre a integrazione Turnstile lato form contatti.
Made-with: Cursor
---
astro.config.mjs | 7 ++
public/images/flags/en.svg | 6 ++
public/images/flags/it.svg | 5 ++
public/images/flags/th.svg | 5 ++
src/components/ContactFormInline.astro | 30 ++++++++
src/components/SiteFooter.astro | 16 +++-
src/data/home/cta.ts | 5 ++
src/layouts/BaseLayout.astro | 5 +-
src/layouts/SubpageLayout.astro | 95 ++++++++++++++++++++++--
src/pages/en/about.astro | 5 ++
src/pages/en/codice-etico.astro | 5 ++
src/pages/en/cookies.astro | 5 ++
src/pages/en/dove-siamo.astro | 5 ++
src/pages/en/gdpr.astro | 5 ++
src/pages/en/index.astro | 5 ++
src/pages/en/modello-organizzativo.astro | 5 ++
src/pages/en/news.astro | 5 ++
src/pages/en/newsletter/grazie.astro | 5 ++
src/pages/en/privacy.astro | 5 ++
src/pages/en/terms.astro | 5 ++
src/pages/index.astro | 84 ++++++++++++++++++++-
src/pages/th/about.astro | 5 ++
src/pages/th/codice-etico.astro | 5 ++
src/pages/th/cookies.astro | 5 ++
src/pages/th/dove-siamo.astro | 5 ++
src/pages/th/gdpr.astro | 5 ++
src/pages/th/index.astro | 5 ++
src/pages/th/modello-organizzativo.astro | 5 ++
src/pages/th/news.astro | 5 ++
src/pages/th/newsletter/grazie.astro | 5 ++
src/pages/th/privacy.astro | 5 ++
src/pages/th/terms.astro | 5 ++
src/scripts/nx-contact-form.ts | 19 +++++
src/scripts/nx-lang-dropdown.ts | 32 ++++++++
34 files changed, 407 insertions(+), 12 deletions(-)
create mode 100644 public/images/flags/en.svg
create mode 100644 public/images/flags/it.svg
create mode 100644 public/images/flags/th.svg
create mode 100644 src/pages/en/about.astro
create mode 100644 src/pages/en/codice-etico.astro
create mode 100644 src/pages/en/cookies.astro
create mode 100644 src/pages/en/dove-siamo.astro
create mode 100644 src/pages/en/gdpr.astro
create mode 100644 src/pages/en/index.astro
create mode 100644 src/pages/en/modello-organizzativo.astro
create mode 100644 src/pages/en/news.astro
create mode 100644 src/pages/en/newsletter/grazie.astro
create mode 100644 src/pages/en/privacy.astro
create mode 100644 src/pages/en/terms.astro
create mode 100644 src/pages/th/about.astro
create mode 100644 src/pages/th/codice-etico.astro
create mode 100644 src/pages/th/cookies.astro
create mode 100644 src/pages/th/dove-siamo.astro
create mode 100644 src/pages/th/gdpr.astro
create mode 100644 src/pages/th/index.astro
create mode 100644 src/pages/th/modello-organizzativo.astro
create mode 100644 src/pages/th/news.astro
create mode 100644 src/pages/th/newsletter/grazie.astro
create mode 100644 src/pages/th/privacy.astro
create mode 100644 src/pages/th/terms.astro
create mode 100644 src/scripts/nx-lang-dropdown.ts
diff --git a/astro.config.mjs b/astro.config.mjs
index 45aeda3..42853d7 100644
--- a/astro.config.mjs
+++ b/astro.config.mjs
@@ -37,4 +37,11 @@ export default defineConfig({
adapter: cloudflare(),
integrations: [alpinejs()],
+ i18n: {
+ defaultLocale: 'it',
+ locales: ['it', 'en', 'th'],
+ routing: {
+ prefixDefaultLocale: false,
+ },
+ },
});
\ No newline at end of file
diff --git a/public/images/flags/en.svg b/public/images/flags/en.svg
new file mode 100644
index 0000000..d9e403a
--- /dev/null
+++ b/public/images/flags/en.svg
@@ -0,0 +1,6 @@
+
diff --git a/public/images/flags/it.svg b/public/images/flags/it.svg
new file mode 100644
index 0000000..e60e5da
--- /dev/null
+++ b/public/images/flags/it.svg
@@ -0,0 +1,5 @@
+
diff --git a/public/images/flags/th.svg b/public/images/flags/th.svg
new file mode 100644
index 0000000..33eb523
--- /dev/null
+++ b/public/images/flags/th.svg
@@ -0,0 +1,5 @@
+
diff --git a/src/components/ContactFormInline.astro b/src/components/ContactFormInline.astro
index 22f1ed3..e37fae2 100644
--- a/src/components/ContactFormInline.astro
+++ b/src/components/ContactFormInline.astro
@@ -5,6 +5,7 @@ const cf = cta.contactForm;
const model = {
actionUrl: cf.actionUrl,
mailto: cf.mailto,
+ turnstileSiteKey: cf.turnstileSiteKey,
notifySubject: cf.notifySubject,
successRedirect: cf.successRedirect,
fieldName: cf.fieldName,
@@ -15,6 +16,8 @@ const model = {
};
const hasFormspree =
typeof cf.actionUrl === 'string' && cf.actionUrl.length > 0;
+const hasTurnstile =
+ typeof cf.turnstileSiteKey === 'string' && cf.turnstileSiteKey.length > 0;
const nextUrl =
typeof cf.successRedirect === 'string' && cf.successRedirect.length > 0
? cf.successRedirect
@@ -178,6 +181,23 @@ const fieldClass =
>
+ {
+ hasFormspree && hasTurnstile ? (
+
+
+
+ Verifica anti-spam: completa il controllo prima di inviare il messaggio.
+
+
+ ) : null
+ }
+
+{
+ hasFormspree && hasTurnstile ? (
+
+ ) : null
+}
+
diff --git a/src/components/SiteFooter.astro b/src/components/SiteFooter.astro
index a0f57c1..3e7e9b0 100644
--- a/src/components/SiteFooter.astro
+++ b/src/components/SiteFooter.astro
@@ -17,6 +17,16 @@ const notifySubject =
const linkClass =
'text-sm text-sky-400/90 transition-colors hover:text-sky-300';
+const path = Astro.url.pathname;
+const localeMatch = path.match(/^\/(en|th)(\/|$)/);
+const currentLocale = localeMatch?.[1] ?? 'it';
+const withLocale = (href: string) => {
+ if (currentLocale === 'it') return href;
+ if (href.startsWith(`/${currentLocale}`)) return href;
+ if (href.startsWith('/#')) return `/${currentLocale}${href}`;
+ if (href.startsWith('/')) return `/${currentLocale}${href}`;
+ return href;
+};
---