mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: footer lang
This commit is contained in:
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 />
|
||||
|
||||
Reference in new issue
Block a user