49fa50c3cd
* Added pt-PT translation Machine translation with human review * Added Flag * Update LanguageSelector.tsx Added Portuguese Option * Update constants.ts Added PT Language constant * Update LanguageSelector.tsx Moved PT to be in the correct alphabetical order * Update constants.ts Moved PT to be in the correct alphabetical order * Update i18next-toolkit.config.cjs
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import React from 'react';
|
|
import { setLanguage, useTranslation } from '@i18next-toolkit/react';
|
|
import { Button, Dropdown } from 'antd';
|
|
import { LuLanguages } from 'react-icons/lu';
|
|
import { CountryFlag } from './CountryFlag';
|
|
|
|
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" />,
|
|
},
|
|
{
|
|
label: 'Português',
|
|
key: 'pt',
|
|
itemIcon: <CountryFlag code="pt" />,
|
|
},
|
|
{
|
|
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';
|