feat(i18n): language switcher on marketing and docs

Merged
KI
2mo ago
+509-29

Adds a language switcher to the marketing footer and docs navbar, following what the best localized landing pages actually do (checked stripe.com/jp and mozilla.org/ja before building):

  • Native <select> (Mozilla's a11y-canonical control), globe icon, no flags — flags name countries, not languages
  • Options in their own language (日本語, Français, …) from LOCALE_LABELS, each with its lang attribute so screen readers pronounce them correctly
  • Auto entry that returns to browser preferences

Mechanism

One LOCALE_COOKIE, honored everywhere: marketing reads it server-side before Accept-Language (#6991's resolution), and inferLocale reads it in the browser — so docs stays fully static while still honoring the choice, and desktop/web pick it up for free. The marketing layout now threads its server-resolved locale into the client provider, closing the last server/client locale split. Applying reloads the page (deliberate — the whole document changes language; Stripe/Mozilla navigate too). When the [lang] URL migration happens, only the apply step changes to a navigation.

Verified (local build)

  • Cookie: superset_locale=ja + Accept-Language: en → serves lang="ja", Japanese hero
  • Invalid cookie → falls back to header negotiation (fr → lang="fr")
  • Footer renders all 17 native names with per-option lang; i18n tests 116, marketing+docs typecheck green
  • The --localized deploy gate from #6991 covers regressions

The four new label strings are left untranslated for the Translate Catalogs bot (64 fills).

https://claude.ai/code/session_012U97YWVsDvZwQkBaSGEmor


Summary by cubic

Adds a language switcher to the marketing footer and docs navbar so visitors can override their browser language preferences. The selection persists in a cookie and takes precedence over Accept-Language.

Behavior

  • The switcher is a native <select> with options in their own language and proper lang attributes.
  • An "Auto" option clears the cookie and returns to browser preference.
  • Choosing a language reloads the page to re-render server-side in the new locale.
  • The marketing layout passes its server-resolved locale into the client provider so both sides agree on the language.
  • The four new label strings are now translated across all enabled locales.

Summary by CodeRabbit

  • New Features
    • Added language selectors to the documentation navigation and marketing footer.
    • Choose a specific supported language or let the site detect it automatically.
    • Language preferences are saved and applied across pages and visits.
    • Added translated selector labels across supported locales.
    • Language selections now load consistently based on saved preferences or browser settings.