mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 22:53:25 +00:00
feat: persist user language
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { ActionIcon, Image } from '@mantine/core';
|
import { ActionIcon, Image } from '@mantine/core';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { LS_LANG_KEY } from '~/constants';
|
||||||
|
|
||||||
export function MantineLanguageSwitcher() {
|
export function MantineLanguageSwitcher() {
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
@@ -8,7 +9,10 @@ export function MantineLanguageSwitcher() {
|
|||||||
<ActionIcon
|
<ActionIcon
|
||||||
variant="light"
|
variant="light"
|
||||||
aria-label="Toggle color scheme"
|
aria-label="Toggle color scheme"
|
||||||
onClick={() => i18n.changeLanguage(newLanguage)}
|
onClick={() => {
|
||||||
|
i18n.changeLanguage(newLanguage);
|
||||||
|
localStorage.setItem(LS_LANG_KEY, newLanguage);
|
||||||
|
}}
|
||||||
size="lg"
|
size="lg"
|
||||||
>
|
>
|
||||||
<Image src={`/icons/${newLanguage}.svg`} alt={newLanguage} w={18} />
|
<Image src={`/icons/${newLanguage}.svg`} alt={newLanguage} w={18} />
|
||||||
|
|||||||
Reference in New Issue
Block a user