From aaf0e52be4a268bdb7edea699ed2d47f88158f2c Mon Sep 17 00:00:00 2001 From: Mark Greene Date: Sun, 4 Oct 2026 19:47:20 +1300 Subject: [PATCH 1/3] Fix: restore redirect to the user's preferred locale Users were no longer sent to their preferred locale. `LocaleRedirector` was emptied in `115fa5aca` after its previous versions caused repeated redirects, and nothing replaced it. **Cause** - The earlier logic compared the best locale (a string) against the current locale entry (an object), so the check was always true on non-default locale pages - That made the redirect fire repeatedly, which led to the logic being removed entirely **Changes** - Derive the current locale from the URL, treating the default locale as unprefixed to match how pages are generated - Redirect only when the best locale differs from the current locale, so it stops after one hop - Redirect users with a saved `preferred-locale` from any page - Redirect users without a saved preference from default-locale URLs only, using their browser language, so shared locale links are respected - Preserve the rest of the path when swapping the locale prefix - Skip `/api` paths --- .../src/components/LocaleRedirector.astro | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/website/src/components/LocaleRedirector.astro b/packages/website/src/components/LocaleRedirector.astro index e4ed25333..80c0afeaa 100644 --- a/packages/website/src/components/LocaleRedirector.astro +++ b/packages/website/src/components/LocaleRedirector.astro @@ -1,3 +1,30 @@ From 92c8b90bb3084447eae534da60b6c20676ba4a23 Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Wed, 7 Oct 2026 16:56:40 -0500 Subject: [PATCH 2/3] remove api check --- packages/website/src/components/LocaleRedirector.astro | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/website/src/components/LocaleRedirector.astro b/packages/website/src/components/LocaleRedirector.astro index 80c0afeaa..50cd05acb 100644 --- a/packages/website/src/components/LocaleRedirector.astro +++ b/packages/website/src/components/LocaleRedirector.astro @@ -3,7 +3,6 @@ import { getBestLocale } from "../core/i18n/getBestLocale"; const pathname = window.location.pathname; - const isAPI = pathname.startsWith("/api"); const hasPreference = localStorage.getItem("preferred-locale") !== null; const bestLocale = getBestLocale(); const currentLocale = @@ -14,7 +13,6 @@ )?.locale ?? locales.default; if ( - !isAPI && bestLocale !== currentLocale && (hasPreference || currentLocale === locales.default) ) { From 02f5cc0686dd55ca6076e08d890312d0c17fffea Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Wed, 7 Oct 2026 17:00:47 -0500 Subject: [PATCH 3/3] remove redundant logic --- packages/website/src/components/LocaleRedirector.astro | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/website/src/components/LocaleRedirector.astro b/packages/website/src/components/LocaleRedirector.astro index 50cd05acb..3805c19cc 100644 --- a/packages/website/src/components/LocaleRedirector.astro +++ b/packages/website/src/components/LocaleRedirector.astro @@ -8,8 +8,7 @@ const currentLocale = locales.supported.find( ({ locale }) => - locale !== locales.default && - (pathname === `/${locale}` || pathname.startsWith(`/${locale}/`)), + pathname === `/${locale}` || pathname.startsWith(`/${locale}/`), )?.locale ?? locales.default; if (