language switcher
This commit is contained in:
parent
0f7297aa70
commit
9e2b7993a8
5 changed files with 30 additions and 10 deletions
|
|
@ -28,6 +28,11 @@
|
||||||
"proxy": {
|
"proxy": {
|
||||||
"title": "Proxy",
|
"title": "Proxy",
|
||||||
"automatic": "Automatic"
|
"automatic": "Automatic"
|
||||||
|
},
|
||||||
|
"languages": {
|
||||||
|
"title": "Language",
|
||||||
|
"japanese": "Japanese",
|
||||||
|
"english": "English"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,11 @@
|
||||||
"proxy": {
|
"proxy": {
|
||||||
"title": "プロキシ",
|
"title": "プロキシ",
|
||||||
"automatic": "自動"
|
"automatic": "自動"
|
||||||
|
},
|
||||||
|
"languages": {
|
||||||
|
"title": "言語",
|
||||||
|
"japanese": "日本語",
|
||||||
|
"english": "英語"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,14 @@ interface Option {
|
||||||
|
|
||||||
const Dropdown = ({
|
const Dropdown = ({
|
||||||
name,
|
name,
|
||||||
|
storageKey,
|
||||||
options,
|
options,
|
||||||
storageKey
|
refresh
|
||||||
}: {
|
}: {
|
||||||
name: string;
|
name: string;
|
||||||
storageKey: string;
|
storageKey: string;
|
||||||
options: Option[];
|
options: Option[];
|
||||||
|
refresh: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
|
||||||
|
|
@ -45,6 +47,9 @@ const Dropdown = ({
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
setChoice(option.id);
|
setChoice(option.id);
|
||||||
localStorage.setItem(storageKey, option.id);
|
localStorage.setItem(storageKey, option.id);
|
||||||
|
if (refresh == true) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{option.label}
|
{option.label}
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,10 @@ import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const Misc = ({ id, active }) => {
|
const Misc = ({ id, active }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const engines = [
|
|
||||||
{ id: "automatic", label: t("settings.proxy.automatic") },
|
const languages = [
|
||||||
{ id: "ultraviolet", label: "Ultraviolet" },
|
{ id: "ja", label: t("settings.languages.japanese") },
|
||||||
{ id: "rammerhead", label: "Rammerhead" },
|
{ id: "en-US", label: t("settings.languages.english") }
|
||||||
{ id: "dynamic", label: "Dynamic" }
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -26,9 +25,10 @@ const Misc = ({ id, active }) => {
|
||||||
className="content-card flex flex-row flex-wrap justify-around"
|
className="content-card flex flex-row flex-wrap justify-around"
|
||||||
>
|
>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
name={t("settings.proxy.title")}
|
name={t("settings.languages.title")}
|
||||||
storageKey="proxy"
|
storageKey="i18nextLng"
|
||||||
options={engines}
|
options={languages}
|
||||||
|
refresh={true}
|
||||||
/>
|
/>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,12 @@ const Proxy = ({ id, active }) => {
|
||||||
variants={settingsPageVariant}
|
variants={settingsPageVariant}
|
||||||
className="content-card flex flex-row flex-wrap justify-around"
|
className="content-card flex flex-row flex-wrap justify-around"
|
||||||
>
|
>
|
||||||
<Dropdown name={t("settings.proxy.title")} storageKey="proxy" options={engines} />
|
<Dropdown
|
||||||
|
name={t("settings.proxy.title")}
|
||||||
|
storageKey="proxy"
|
||||||
|
options={engines}
|
||||||
|
refresh={false}
|
||||||
|
/>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue