2020-01-22 16:25:04 +02:00
|
|
|
import React from "react";
|
2020-01-26 17:14:31 -03:00
|
|
|
import { useTranslation } from "react-i18next";
|
2020-01-22 16:25:04 +02:00
|
|
|
|
|
|
|
export function LanguageList<T>({
|
|
|
|
onClick,
|
|
|
|
languages,
|
2020-01-24 12:04:54 +02:00
|
|
|
currentLanguage,
|
2020-01-22 16:25:04 +02:00
|
|
|
}: {
|
|
|
|
languages: { lng: string; label: string }[];
|
|
|
|
onClick: (value: string) => void;
|
|
|
|
currentLanguage: string;
|
|
|
|
}) {
|
2020-01-26 17:14:31 -03:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
2020-01-22 16:25:04 +02:00
|
|
|
return (
|
2020-01-24 19:10:44 +01:00
|
|
|
<React.Fragment>
|
|
|
|
<select
|
|
|
|
className="language-select"
|
|
|
|
onChange={({ target }) => onClick(target.value)}
|
|
|
|
value={currentLanguage}
|
2020-01-26 17:14:31 -03:00
|
|
|
aria-label={t("buttons.selectLanguage")}
|
2020-01-24 19:10:44 +01:00
|
|
|
>
|
|
|
|
{languages.map(language => (
|
|
|
|
<option key={language.lng} value={language.lng}>
|
2020-01-22 16:25:04 +02:00
|
|
|
{language.label}
|
2020-01-24 19:10:44 +01:00
|
|
|
</option>
|
|
|
|
))}
|
|
|
|
</select>
|
|
|
|
</React.Fragment>
|
2020-01-22 16:25:04 +02:00
|
|
|
);
|
|
|
|
}
|