2021-06-21 08:44:43 -04:00
|
|
|
import ComboBox from "../ui/ComboBox";
|
2021-07-05 05:59:48 -04:00
|
|
|
import { dispatch } from "../../redux";
|
2021-06-21 08:44:43 -04:00
|
|
|
import { connectState } from "../../redux/connector";
|
2021-07-04 07:09:39 -04:00
|
|
|
import { Language, LanguageEntry, Languages } from "../../context/Locale";
|
2021-06-21 08:44:43 -04:00
|
|
|
|
2021-07-05 05:59:48 -04:00
|
|
|
type Props = {
|
2021-06-21 08:44:43 -04:00
|
|
|
locale: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export function LocaleSelector(props: Props) {
|
|
|
|
return (
|
|
|
|
<ComboBox
|
|
|
|
value={props.locale}
|
|
|
|
onChange={e =>
|
2021-07-05 05:59:48 -04:00
|
|
|
dispatch({
|
2021-06-21 08:44:43 -04:00
|
|
|
type: "SET_LOCALE",
|
2021-07-04 07:09:39 -04:00
|
|
|
locale: e.currentTarget.value as Language
|
2021-06-21 08:44:43 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{Object.keys(Languages).map(x => {
|
2021-07-04 07:09:39 -04:00
|
|
|
const l = Languages[x as keyof typeof Languages];
|
2021-06-21 08:44:43 -04:00
|
|
|
return (
|
|
|
|
<option value={x}>
|
|
|
|
{l.emoji} {l.display}
|
|
|
|
</option>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</ComboBox>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connectState(
|
|
|
|
LocaleSelector,
|
|
|
|
state => {
|
|
|
|
return {
|
|
|
|
locale: state.locale
|
|
|
|
};
|
2021-07-05 05:59:48 -04:00
|
|
|
}
|
2021-06-21 08:44:43 -04:00
|
|
|
);
|