import {} from '@blitzkit/core'; import { DEFAULT_LOCALE, SUPPORTED_LOCALES, SUPPORTED_LOCALE_FLAGS, localizedStrings, } from '@blitzkit/i18n'; import { Select } from '@radix-ui/themes'; import type { LocaleAcceptorProps } from '../hooks/useLocale'; import { BlitzKitTheme } from './BlitzKitTheme'; export function LocaleSwitcherThemeWrapper({ locale }: LocaleAcceptorProps) { return ( ); } export function LocaleSwitcher({ locale }: LocaleAcceptorProps) { return ( { localStorage.setItem('preferred-locale', locale); let rawPath = window.location.pathname; for (const supportedLocale of SUPPORTED_LOCALES) { if (window.location.pathname.startsWith(`/${supportedLocale}`)) { rawPath = rawPath.replace(`/${supportedLocale}`, ''); break; } } window.location.pathname = `${ locale === DEFAULT_LOCALE ? '' : `/${locale}` }${rawPath}`; }} > {SUPPORTED_LOCALES.map((locale) => ( {SUPPORTED_LOCALE_FLAGS[locale]}{' '} {localizedStrings[locale].common.locales[locale]} ))} ); }