mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +00:00
feat: update default layout
This commit is contained in:
21
inertia/components/common/locale_switcher.tsx
Normal file
21
inertia/components/common/locale_switcher.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { ActionIcon, Image } from '@mantine/core';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { LS_LANG_KEY } from '~/constants';
|
||||
|
||||
export function LocaleSwitcher() {
|
||||
const { i18n } = useTranslation();
|
||||
const newLanguage = i18n.language === 'en' ? 'fr' : 'en';
|
||||
return (
|
||||
<ActionIcon
|
||||
variant="light"
|
||||
aria-label="Toggle color scheme"
|
||||
onClick={() => {
|
||||
i18n.changeLanguage(newLanguage);
|
||||
localStorage.setItem(LS_LANG_KEY, newLanguage);
|
||||
}}
|
||||
size="lg"
|
||||
>
|
||||
<Image src={`/icons/${newLanguage}.svg`} alt={newLanguage} w={18} />
|
||||
</ActionIcon>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user