Impedisce l'auto-traduzione del browser e fissa il locale TH/EN esplicito.
Chrome traduceva il tailandese in inglese allo scroll; html translate=no e prop locale sulle route. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -20,11 +20,12 @@ const canonicalUrl = Astro.url.toString();
|
|||||||
---
|
---
|
||||||
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang={htmlLang} class="bg-nx-bg">
|
<html lang={htmlLang} class="bg-nx-bg" translate="no">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="description" content={description} />
|
<meta name="description" content={description} />
|
||||||
|
<meta name="google" content="notranslate" />
|
||||||
<link rel="canonical" href={canonicalUrl} />
|
<link rel="canonical" href={canonicalUrl} />
|
||||||
<meta name="theme-color" content="#030712" />
|
<meta name="theme-color" content="#030712" />
|
||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
@ -46,7 +47,7 @@ const canonicalUrl = Astro.url.toString();
|
|||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
/>
|
/>
|
||||||
</head>
|
</head>
|
||||||
<body class="min-h-screen">
|
<body class="notranslate min-h-screen">
|
||||||
<slot />
|
<slot />
|
||||||
<CookieConsent />
|
<CookieConsent />
|
||||||
<ChatGateModal />
|
<ChatGateModal />
|
||||||
|
|||||||
@ -2,4 +2,4 @@
|
|||||||
import Page from '../index.astro';
|
import Page from '../index.astro';
|
||||||
---
|
---
|
||||||
|
|
||||||
<Page />
|
<Page locale="en" />
|
||||||
|
|||||||
@ -16,10 +16,19 @@ import {
|
|||||||
getFaq,
|
getFaq,
|
||||||
getCta,
|
getCta,
|
||||||
} from '../data/home';
|
} from '../data/home';
|
||||||
|
import type { SupportedLocale } from '../data/home/navigation';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
/** Locale esplicito dalle route /en e /th (evita ambiguità se la page è importata come componente). */
|
||||||
|
locale?: SupportedLocale;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { locale: localeProp } = Astro.props;
|
||||||
const path = Astro.url.pathname;
|
const path = Astro.url.pathname;
|
||||||
const localeMatch = path.match(/^\/(en|th)(\/|$)/);
|
const localeMatch = path.match(/^\/(en|th)(\/|$)/);
|
||||||
const currentLocale = (localeMatch?.[1] ?? 'it') as 'it' | 'en' | 'th';
|
const currentLocale = (localeProp ??
|
||||||
|
(localeMatch?.[1] as SupportedLocale | undefined) ??
|
||||||
|
'it') as SupportedLocale;
|
||||||
const navigation = getNavigation(currentLocale);
|
const navigation = getNavigation(currentLocale);
|
||||||
const siteMeta = getSiteMeta(currentLocale);
|
const siteMeta = getSiteMeta(currentLocale);
|
||||||
const hero = getHero(currentLocale);
|
const hero = getHero(currentLocale);
|
||||||
|
|||||||
@ -2,4 +2,4 @@
|
|||||||
import Page from '../index.astro';
|
import Page from '../index.astro';
|
||||||
---
|
---
|
||||||
|
|
||||||
<Page />
|
<Page locale="th" />
|
||||||
|
|||||||
@ -75,8 +75,11 @@ function measureHeaderAndSync(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function bind(): void {
|
function bind(): void {
|
||||||
const path = window.location.pathname;
|
const path = window.location.pathname.replace(/\/$/, '') || '/';
|
||||||
if (path !== '/' && path !== '/index.html') return;
|
// Home IT (`/`) e home localizzate (`/en`, `/th`).
|
||||||
|
if (path !== '/' && path !== '/index.html' && path !== '/en' && path !== '/th') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const header = document.querySelector('header');
|
const header = document.querySelector('header');
|
||||||
measureHeaderAndSync();
|
measureHeaderAndSync();
|
||||||
|
|||||||
Reference in New Issue
Block a user