2020-09-21 06:31:53 +02:00
|
|
|
import React from 'react';
|
2020-09-08 04:48:40 +02:00
|
|
|
import { menuOptions } from 'lib/lang';
|
2020-09-17 09:17:11 +02:00
|
|
|
import useLocale from 'hooks/useLocale';
|
2020-09-21 06:31:53 +02:00
|
|
|
import MenuButton from 'components/common/MenuButton';
|
2020-09-17 09:17:11 +02:00
|
|
|
import Globe from 'assets/globe.svg';
|
2020-10-02 21:15:42 +02:00
|
|
|
import styles from './LanguageButton.module.css';
|
2020-09-07 10:22:16 +02:00
|
|
|
|
2020-09-21 06:31:53 +02:00
|
|
|
export default function LanguageButton() {
|
2020-09-09 05:46:31 +02:00
|
|
|
const [locale, setLocale] = useLocale();
|
2020-09-07 10:22:16 +02:00
|
|
|
|
|
|
|
function handleSelect(value) {
|
2020-09-09 05:46:31 +02:00
|
|
|
setLocale(value);
|
2020-09-07 10:22:16 +02:00
|
|
|
}
|
|
|
|
|
2021-05-20 22:21:30 +02:00
|
|
|
switch (locale) {
|
2021-05-21 19:55:37 +02:00
|
|
|
case 'zh-CN':
|
2021-05-20 22:21:30 +02:00
|
|
|
import('@fontsource/noto-sans-sc/400.css');
|
|
|
|
import('@fontsource/noto-sans-sc/500.css');
|
|
|
|
import('@fontsource/noto-sans-sc/700.css');
|
|
|
|
break;
|
|
|
|
case 'zh-TW':
|
|
|
|
import('@fontsource/noto-sans-tc/400.css');
|
|
|
|
import('@fontsource/noto-sans-tc/500.css');
|
|
|
|
import('@fontsource/noto-sans-tc/700.css');
|
|
|
|
break;
|
|
|
|
case 'ja-JP':
|
|
|
|
import('@fontsource/noto-sans-jp/400.css');
|
|
|
|
import('@fontsource/noto-sans-jp/500.css');
|
|
|
|
import('@fontsource/noto-sans-jp/700.css');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-09-07 10:22:16 +02:00
|
|
|
return (
|
2021-05-20 22:21:30 +02:00
|
|
|
<MenuButton
|
|
|
|
icon={<Globe />}
|
|
|
|
options={menuOptions}
|
|
|
|
value={locale}
|
|
|
|
menuClassName={styles.menu}
|
|
|
|
renderValue={option => option?.display}
|
|
|
|
onSelect={handleSelect}
|
|
|
|
/>
|
2020-09-07 10:22:16 +02:00
|
|
|
);
|
|
|
|
}
|