2021-12-11 11:56:33 +00:00
|
|
|
import { useApplicationState } from "../../mobx/State";
|
2021-07-05 11:23:23 +01:00
|
|
|
|
|
|
|
import { Language, Languages } from "../../context/Locale";
|
|
|
|
|
|
|
|
import ComboBox from "../ui/ComboBox";
|
2021-06-21 13:44:43 +01:00
|
|
|
|
2021-12-11 11:56:33 +00:00
|
|
|
/**
|
|
|
|
* Component providing a language selector combobox.
|
|
|
|
* Note: this is not an observer but this is fine as we are just using a combobox.
|
|
|
|
*/
|
|
|
|
export default function LocaleSelector() {
|
|
|
|
const locale = useApplicationState().locale;
|
2021-06-21 13:44:43 +01:00
|
|
|
|
2021-07-05 11:25:20 +01:00
|
|
|
return (
|
|
|
|
<ComboBox
|
2021-12-11 11:56:33 +00:00
|
|
|
value={locale.getLanguage()}
|
2021-07-05 11:25:20 +01:00
|
|
|
onChange={(e) =>
|
2021-12-11 11:56:33 +00:00
|
|
|
locale.setLanguage(e.currentTarget.value as Language)
|
2021-07-05 11:25:20 +01:00
|
|
|
}>
|
|
|
|
{Object.keys(Languages).map((x) => {
|
|
|
|
const l = Languages[x as keyof typeof Languages];
|
|
|
|
return (
|
2021-08-05 14:47:00 +01:00
|
|
|
<option value={x} key={x}>
|
2021-07-05 11:25:20 +01:00
|
|
|
{l.emoji} {l.display}
|
|
|
|
</option>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</ComboBox>
|
|
|
|
);
|
2021-06-21 13:44:43 +01:00
|
|
|
}
|