import React from 'react'; import PropTypes from 'prop-types'; import { compose } from 'redux'; import { translate } from 'react-i18next'; import i18n from '../../../i18n'; import { UncontrolledDropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap'; import reduxConnect from '../../../redux/utils/connect'; import Flag from 'react-flagkit'; const langCountry = { en: 'US', ar: 'SA', fr: 'FR' }; function LangSettingsMenu(props) { const { t, base: { langs, activeLang }, actions, direction = '' } = props; const chooseLang = (e) => { const newLang = e.target.dataset.lang; actions.chooseLanguage(newLang); i18n.changeLanguage(newLang); }; const isRTL = document.documentElement.dir === 'rtl'; const dropDownProps = {}; if (direction) { dropDownProps.direction = direction; } return (
{t('langs.chooseLanguage')}
{langs.map((lang, i) => { const translateTarget = 'langs.' + lang; return ( {t(translateTarget)} ); })}
); } LangSettingsMenu.propTypes = { t: PropTypes.func.isRequired, base: PropTypes.object.isRequired, actions: PropTypes.object.isRequired, direction: PropTypes.string }; const applyDecorators = compose( reduxConnect('base', ['common', 'base']), translate(['common'], { wait: true }) ); export default applyDecorators(LangSettingsMenu);