feat: smarter preferred lang detection (#8205)

This commit is contained in:
David Luzar 2024-07-04 17:55:35 +02:00 committed by GitHub
parent d9258a736b
commit 148b895f46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 48 additions and 25 deletions

View file

@ -0,0 +1,25 @@
import { useSetAtom } from "jotai";
import React from "react";
import { useI18n, languages } from "../../packages/excalidraw/i18n";
import { appLangCodeAtom } from "./language-state";
export const LanguageList = ({ style }: { style?: React.CSSProperties }) => {
const { t, langCode } = useI18n();
const setLangCode = useSetAtom(appLangCodeAtom);
return (
<select
className="dropdown-select dropdown-select__language"
onChange={({ target }) => setLangCode(target.value)}
value={langCode}
aria-label={t("buttons.selectLanguage")}
style={style}
>
{languages.map((lang) => (
<option key={lang.code} value={lang.code}>
{lang.label}
</option>
))}
</select>
);
};