excalidraw/src/components/LanguageList.tsx

32 lines
738 B
TypeScript
Raw Normal View History

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