import cn from "classnames"; import { Flag } from "src/components"; import { useLocaleState } from "src/context"; import { useTheme } from "src/hooks"; import { changeLocale, getFlagCodeForLocale, intl, localeOptions } from "src/locale"; import styles from "./LocalePicker.module.css"; function LocalePicker() { const { locale, setLocale } = useLocaleState(); const { getTheme } = useTheme(); const changeTo = (lang: string) => { changeLocale(lang); setLocale(lang); location.reload(); }; const classes = ["btn", "dropdown-toggle", "btn-sm", styles.btn]; const cns = cn(...classes, getTheme() === "dark" ? "btn-ghost-dark" : "btn-ghost-light"); return (
{localeOptions.map((item) => { return ( { e.preventDefault(); changeTo(item[0]); }} > {" "} {intl.formatMessage({ id: `locale-${item[1]}` })} ); })}
); //
// // // // // // {localeOptions.map((item) => { // return ( // } // onClick={() => changeTo(item[0])} // key={`locale-${item[0]}`}> // {intl.formatMessage({ id: `locale-${item[1]}` })} // // ); // })} // // // } export { LocalePicker };