You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
726 B
31 lines
726 B
import {useRouter} from 'next/router';
|
|
import ReactFlagsSelect from 'react-flags-select';
|
|
import {getLocaleShort} from '@services/utils';
|
|
|
|
|
|
const LanguageSelector = (props) => {
|
|
const router = useRouter();
|
|
const localeShort = getLocaleShort();
|
|
|
|
const selectHandler = (e) => {
|
|
let locale = e.toLowerCase();
|
|
if (locale === 'gb') locale = 'en';
|
|
router.push('', '', {locale});
|
|
};
|
|
return (
|
|
<ReactFlagsSelect
|
|
onSelect={selectHandler}
|
|
countries={
|
|
// ["GB", "FR", "ES", "DE", "RU"]
|
|
['GB', 'FR']
|
|
}
|
|
selected={localeShort}
|
|
customLabels={{GB: 'English', FR: 'Francais'}}
|
|
{...props}
|
|
className="menu-flags"
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default LanguageSelector;
|