LanguageList.tsx 751 B

12345678910111213141516171819202122232425
  1. import React from "react";
  2. import { useI18n, languages } from "@excalidraw/excalidraw/i18n";
  3. import { useSetAtom } from "../app-jotai";
  4. import { appLangCodeAtom } from "./language-state";
  5. export const LanguageList = ({ style }: { style?: React.CSSProperties }) => {
  6. const { t, langCode } = useI18n();
  7. const setLangCode = useSetAtom(appLangCodeAtom);
  8. return (
  9. <select
  10. className="dropdown-select dropdown-select__language"
  11. onChange={({ target }) => setLangCode(target.value)}
  12. value={langCode}
  13. aria-label={t("buttons.selectLanguage")}
  14. style={style}
  15. >
  16. {languages.map((lang) => (
  17. <option key={lang.code} value={lang.code}>
  18. {lang.label}
  19. </option>
  20. ))}
  21. </select>
  22. );
  23. };