2024-02-11 16:10:38 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { setLanguage, useTranslation } from '@i18next-toolkit/react';
|
|
|
|
import { Button, Dropdown } from 'antd';
|
|
|
|
import { LuLanguages } from 'react-icons/lu';
|
2024-03-17 16:57:02 +00:00
|
|
|
import { CountryFlag } from './CountryFlag';
|
2024-02-11 16:10:38 +00:00
|
|
|
|
|
|
|
export const LanguageSelector: React.FC = React.memo(() => {
|
|
|
|
const { i18n } = useTranslation();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Dropdown
|
|
|
|
trigger={['click']}
|
|
|
|
placement="bottomRight"
|
|
|
|
menu={{
|
|
|
|
selectedKeys: [i18n.language],
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
label: 'English',
|
|
|
|
key: 'en',
|
|
|
|
itemIcon: <CountryFlag code="en" />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Deutsch',
|
|
|
|
key: 'de',
|
|
|
|
itemIcon: <CountryFlag code="de" />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Français',
|
|
|
|
key: 'fr',
|
|
|
|
itemIcon: <CountryFlag code="fr" />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '日本語',
|
|
|
|
key: 'jp',
|
|
|
|
itemIcon: <CountryFlag code="jp" />,
|
|
|
|
},
|
2024-04-15 16:14:56 +00:00
|
|
|
{
|
|
|
|
label: 'Português',
|
|
|
|
key: 'pt',
|
|
|
|
itemIcon: <CountryFlag code="pt" />,
|
|
|
|
},
|
2024-02-11 16:10:38 +00:00
|
|
|
{
|
|
|
|
label: 'Русский',
|
|
|
|
key: 'ru',
|
|
|
|
itemIcon: <CountryFlag code="ru" />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '简体中文',
|
|
|
|
key: 'zh',
|
|
|
|
itemIcon: <CountryFlag code="zh" />,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
onClick: (info) => {
|
|
|
|
setLanguage(info.key);
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Button
|
|
|
|
icon={<LuLanguages className="anticon" />}
|
|
|
|
shape="circle"
|
|
|
|
size="large"
|
|
|
|
/>
|
|
|
|
</Dropdown>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
LanguageSelector.displayName = 'LanguageSelector';
|