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.

30 lines
798 B

  1. /* eslint react/prop-types: 0 */
  2. import React from "react";
  3. import ReactFlagsSelect from "react-flags-select";
  4. import "react-flags-select/css/react-flags-select.css";
  5. import i18n from "../../i18n";
  6. const LanguageSelector = () => {
  7. const selectHandler = e => {
  8. let locale = e.toLowerCase();
  9. if (locale === "gb") locale = "en";
  10. i18n.changeLanguage(locale);
  11. };
  12. let locale = i18n.language? i18n.language.substring(0, 2).toUpperCase() : "EN";
  13. if (locale === "EN") locale = "GB";
  14. return (
  15. <ReactFlagsSelect
  16. onSelect={selectHandler}
  17. countries={["GB", "FR", "ES", "DE", "RU"]}
  18. showOptionLabel={false}
  19. defaultCountry={locale}
  20. selectedSize={15}
  21. optionsSize={22}
  22. showSelectedLabel={false}
  23. />
  24. );
  25. };
  26. export default LanguageSelector;