Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 356x 437x 437x 437x 12x 437x 12x 12x 437x | import { ReactElement, ChangeEvent } from "react";
import { useTranslation } from "react-i18next";
import { TFunction } from "i18next";
import { setLocale } from "shared/utils/setLocale";
import { Dropdown } from "client/components/Dropdown";
export const LanguageSelector = (): ReactElement => {
const { t, i18n } = useTranslation();
const language = i18n.language;
// Language toggle
const toggle = async (lng: string): Promise<TFunction> =>
await i18n.changeLanguage(lng);
const setLanguage = (event: ChangeEvent<HTMLSelectElement>): void => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
toggle(event.target.value);
setLocale(event.target.value);
};
const options = [
{ value: "en", title: t("language.englishShort") },
{ value: "fi", title: t("language.finnishShort") },
];
return (
<Dropdown
id="language"
selectedValue={language}
onChange={setLanguage}
options={options}
/>
);
};
|