import { useAppState } from '@components/common/context/app.js'; import { switchLocalePath } from '@evershop/evershop/lib/locale/localeResolution'; import { _ } from '@evershop/evershop/lib/locale/translate/_'; import React from 'react'; /** Native display name for a locale code, falling back to the upper-cased code. */ function localeLabel(code: string): string { try { return new Intl.DisplayNames([code], { type: 'language' }).of(code) ?? code; } catch { return code.toUpperCase(); } } /** * Storefront language switcher (spec §7). Reads the enabled locales + current/default * locale from `eContext` (via `useAppState`, so it works during SSR and on the client), * and on change navigates to the same page under the chosen locale (prefix swap, shared * slugs). Renders nothing when fewer than two locales are enabled — so single-language * stores show no switcher. Plain ` {availableLocales.map((code) => ( ))} ); }