mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 17:55:08 +01:00
31 lines
765 B
JavaScript
31 lines
765 B
JavaScript
import { languages } from 'lib/lang';
|
|
import useLocale from 'hooks/useLocale';
|
|
import MenuButton from 'components/common/MenuButton';
|
|
import Globe from 'assets/globe.svg';
|
|
import styles from './LanguageButton.module.css';
|
|
import { Icon } from 'react-basics';
|
|
|
|
export default function LanguageButton() {
|
|
const { locale, saveLocale } = useLocale();
|
|
const menuOptions = Object.keys(languages).map(key => ({ ...languages[key], value: key }));
|
|
|
|
function handleSelect(value) {
|
|
saveLocale(value);
|
|
}
|
|
|
|
return (
|
|
<MenuButton
|
|
options={menuOptions}
|
|
value={locale}
|
|
menuClassName={styles.menu}
|
|
buttonVariant="light"
|
|
onSelect={handleSelect}
|
|
hideLabel
|
|
>
|
|
<Icon>
|
|
<Globe />
|
|
</Icon>
|
|
</MenuButton>
|
|
);
|
|
}
|