2024-08-31 15:39:05 +02:00
|
|
|
import { localeAtom, translationAtom } from "@/atoms/translations-atom";
|
|
|
|
import { useAtomValue, useSetAtom } from "jotai";
|
|
|
|
|
|
|
|
const locales = {
|
|
|
|
en: "English",
|
|
|
|
ru: "Русский",
|
2024-09-01 14:01:45 +02:00
|
|
|
ja: "日本語",
|
2024-08-31 15:39:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const LanguageSwitcher = () => {
|
|
|
|
const setLocale = useSetAtom(localeAtom);
|
|
|
|
const t = useAtomValue(translationAtom);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div className="flex flex-col gap-2">
|
2024-09-01 14:01:45 +02:00
|
|
|
<p className="text-sm font-medium">{t("APP.SETTINGS.CHANGE_LANG")}</p>
|
2024-08-31 15:39:05 +02:00
|
|
|
<select
|
|
|
|
data-choose-theme
|
|
|
|
className="select select-primary"
|
2024-09-01 14:01:45 +02:00
|
|
|
onChange={(e) => setLocale(e.target.value as keyof typeof locales)}
|
2024-08-31 15:39:05 +02:00
|
|
|
>
|
|
|
|
{Object.entries(locales).map((entry) => {
|
|
|
|
const [locale, label] = entry;
|
|
|
|
return (
|
|
|
|
<option value={locale} key={locale}>
|
|
|
|
{label.toLocaleUpperCase()}
|
|
|
|
</option>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default LanguageSwitcher;
|