2020-01-22 16:25:04 +02:00
|
|
|
import React from "react";
|
2020-10-19 17:14:28 +03:00
|
|
|
import clsx from "clsx";
|
2021-01-04 02:21:52 +05:30
|
|
|
import * as i18n from "../../i18n";
|
2020-01-22 16:25:04 +02:00
|
|
|
|
2020-05-20 16:21:37 +03:00
|
|
|
export const LanguageList = ({
|
2020-01-31 21:06:06 +00:00
|
|
|
onChange,
|
2020-03-07 10:20:38 -05:00
|
|
|
languages = i18n.languages,
|
2021-01-04 02:21:52 +05:30
|
|
|
currentLangCode = i18n.getLanguage().code,
|
2020-02-21 14:34:18 -05:00
|
|
|
floating,
|
2020-01-22 16:25:04 +02:00
|
|
|
}: {
|
2021-01-04 02:21:52 +05:30
|
|
|
languages?: { code: string; label: string }[];
|
|
|
|
onChange: (langCode: i18n.Language["code"]) => void;
|
|
|
|
currentLangCode?: i18n.Language["code"];
|
2020-02-21 14:34:18 -05:00
|
|
|
floating?: boolean;
|
2020-05-20 16:21:37 +03:00
|
|
|
}) => (
|
|
|
|
<React.Fragment>
|
|
|
|
<select
|
2020-10-19 17:14:28 +03:00
|
|
|
className={clsx("dropdown-select dropdown-select__language", {
|
|
|
|
"dropdown-select--floating": floating,
|
|
|
|
})}
|
2020-05-20 16:21:37 +03:00
|
|
|
onChange={({ target }) => onChange(target.value)}
|
2021-01-04 02:21:52 +05:30
|
|
|
value={currentLangCode}
|
2020-05-20 16:21:37 +03:00
|
|
|
aria-label={i18n.t("buttons.selectLanguage")}
|
|
|
|
>
|
2021-01-07 21:39:57 +02:00
|
|
|
<option key={i18n.defaultLang.code} value={i18n.defaultLang.code}>
|
|
|
|
{i18n.defaultLang.label}
|
|
|
|
</option>
|
2021-01-04 02:21:52 +05:30
|
|
|
{languages.map((lang) => (
|
|
|
|
<option key={lang.code} value={lang.code}>
|
|
|
|
{lang.label}
|
2020-05-20 16:21:37 +03:00
|
|
|
</option>
|
|
|
|
))}
|
|
|
|
</select>
|
|
|
|
</React.Fragment>
|
|
|
|
);
|