feat: footer lang

This commit is contained in:
tresabhi committed 2025-01-15 13:10:57 -06:00
1 parent 4e80490fd4
commit baa16840df
5 files changed
+37 -19

No files matched your search

@@ -7,6 +7,15 @@ import {
} 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 (
<BlitzKitTheme style={{ background: 'transparent' }}>
<LocaleSwitcher locale={locale} />
</BlitzKitTheme>
);
}
export function LocaleSwitcher({ locale }: LocaleAcceptorProps) {
return (
@@ -14,7 +23,19 @@ export function LocaleSwitcher({ locale }: LocaleAcceptorProps) {
defaultValue={locale}
onValueChange={(locale) => {
localStorage.setItem('preferred-locale', locale);
window.location.pathname = `/${locale === DEFAULT_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}`;
}}
>
<Select.Trigger />