mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-19 01:14:38 +08:00
Update settings i18n
This commit is contained in:
@@ -9,7 +9,7 @@ import { ConfigType } from "../config.ts";
|
||||
import SettingsCheckbox from "../components/SettingsCheckbox.tsx";
|
||||
import SettingsContext from "../components/SettingsContext.tsx";
|
||||
import SettingsText from "../components/SettingsText.tsx";
|
||||
import { i18n_map } from "../server/i18n.ts";
|
||||
import t from "../server/i18n.ts";
|
||||
|
||||
export type SettingsProps = {
|
||||
show: boolean;
|
||||
@@ -53,7 +53,7 @@ export default class Settings extends Component<SettingsProps> {
|
||||
};
|
||||
const loadData = () => {
|
||||
fetchSettings().catch((e) => {
|
||||
set_error("Failed to fetch settings.");
|
||||
set_error(t("settings.failed"));
|
||||
console.error(e);
|
||||
});
|
||||
};
|
||||
@@ -71,7 +71,7 @@ export default class Settings extends Component<SettingsProps> {
|
||||
const dlg = useRef<Dialog>();
|
||||
const showDlg = () => {
|
||||
if (!changed.size) {
|
||||
show_snack("Nothing was changed.");
|
||||
show_snack(t("settings.no_changed"));
|
||||
return;
|
||||
}
|
||||
dlg.current?.MDComponent?.show();
|
||||
@@ -81,14 +81,13 @@ export default class Settings extends Component<SettingsProps> {
|
||||
saveSettings().then((d) => {
|
||||
set_disabled(false);
|
||||
show_snack(
|
||||
"Saved." +
|
||||
(d.is_unsafe
|
||||
? " Some settings require a restart to take effect."
|
||||
: ""),
|
||||
t("settings.saved") +
|
||||
(d.is_unsafe ? t("settings.need_restart") : ""),
|
||||
);
|
||||
loadData();
|
||||
}).catch((e) => {
|
||||
set_disabled(false);
|
||||
show_snack("Failed to save settings.");
|
||||
show_snack(t("settings.failed"));
|
||||
console.error(e);
|
||||
});
|
||||
};
|
||||
@@ -101,28 +100,28 @@ export default class Settings extends Component<SettingsProps> {
|
||||
<SettingsCheckbox
|
||||
name="download_original_img"
|
||||
checked={settings.download_original_img}
|
||||
description="Download original images."
|
||||
description={t("settings.download_original_img")}
|
||||
/>
|
||||
<SettingsCheckbox
|
||||
name="ex"
|
||||
checked={settings.ex}
|
||||
description="Use exhentai.org."
|
||||
description={t("settings.ex")}
|
||||
/>
|
||||
<SettingsCheckbox
|
||||
name="mpv"
|
||||
checked={settings.mpv}
|
||||
description="Fetch page data from Multi-Page Viewer."
|
||||
description={t("settings.mpv")}
|
||||
/>
|
||||
<SettingsText
|
||||
name="base"
|
||||
value={settings.base}
|
||||
description="Download location:"
|
||||
description={t("settings.base")}
|
||||
type="text"
|
||||
/>
|
||||
<SettingsText
|
||||
name="ua"
|
||||
value={settings.ua ? settings.ua : ""}
|
||||
description="User Agent:"
|
||||
description={t("settings.ua")}
|
||||
type="text"
|
||||
ref={ref}
|
||||
>
|
||||
@@ -136,60 +135,62 @@ export default class Settings extends Component<SettingsProps> {
|
||||
}
|
||||
}}
|
||||
>
|
||||
Use current browser's user agent.
|
||||
{t("settings.ua_now")}
|
||||
</Button>
|
||||
</SettingsText>
|
||||
<SettingsText
|
||||
name="cookies"
|
||||
value={new_cookies}
|
||||
description="Cookies:"
|
||||
description={t("settings.cookies")}
|
||||
type="text"
|
||||
set_value={set_new_cookies}
|
||||
label={`Enter${
|
||||
settings.cookies ? " new" : ""
|
||||
} cookies here.`}
|
||||
label={t(
|
||||
`settings.enter${
|
||||
settings.cookies ? "_new" : ""
|
||||
}_cookies`,
|
||||
)}
|
||||
/>
|
||||
<SettingsText
|
||||
name="max_task_count"
|
||||
value={settings.max_task_count}
|
||||
description="Maximum number of parallel tasks:"
|
||||
description={t("settings.max_task_count")}
|
||||
type="number"
|
||||
min={1}
|
||||
/>
|
||||
<SettingsText
|
||||
name="max_retry_count"
|
||||
value={settings.max_retry_count}
|
||||
description="Maximum retry count:"
|
||||
description={t("settings.max_retry_count")}
|
||||
type="number"
|
||||
min={1}
|
||||
/>
|
||||
<SettingsText
|
||||
name="max_download_img_count"
|
||||
value={settings.max_download_img_count}
|
||||
description="Maximum number of parallel downloads of images:"
|
||||
description={t("settings.max_download_img_count")}
|
||||
type="number"
|
||||
min={1}
|
||||
/>
|
||||
</SettingsContext>
|
||||
<Button onClick={loadData}>Reload</Button>
|
||||
<Button onClick={showDlg} disabled={disabled}>Save</Button>
|
||||
<Button onClick={loadData}>{t("common.reload")}</Button>
|
||||
<Button onClick={showDlg} disabled={disabled}>
|
||||
{t("common.save")}
|
||||
</Button>
|
||||
<Dialog ref={dlg} onAccept={save}>
|
||||
<Dialog.Header>
|
||||
Do you want to save settings?
|
||||
</Dialog.Header>
|
||||
<Dialog.Header>{t("settings.save_dlg")}</Dialog.Header>
|
||||
<Dialog.Footer>
|
||||
<Dialog.FooterButton accept={true}>
|
||||
Yes
|
||||
{t("common.yes")}
|
||||
</Dialog.FooterButton>
|
||||
<Dialog.FooterButton cancel={true}>
|
||||
No
|
||||
{t("common.no")}
|
||||
</Dialog.FooterButton>
|
||||
</Dialog.Footer>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
data = <div class={tw`text-red-500`}>Loading...</div>;
|
||||
data = <div class={tw`text-red-500`}>{t("common.loading")}</div>;
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
|
||||
@@ -6,8 +6,8 @@ import { pick } from "accept-language-parser/";
|
||||
|
||||
const whole_maps = new Map<string, I18NMap>();
|
||||
const LANGUAGES = ["zh-cn"];
|
||||
type MODULE = "common";
|
||||
const MODULES: MODULE[] = ["common"];
|
||||
type MODULE = "common" | "settings";
|
||||
const MODULES: MODULE[] = ["common", "settings"];
|
||||
|
||||
export async function load_translation(signal?: AbortSignal) {
|
||||
const base = import.meta.resolve("../translation").slice(8);
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
{
|
||||
"title": "EH Downloader"
|
||||
"title": "EH Downloader",
|
||||
"loading": "Loading...",
|
||||
"reload": "Reload",
|
||||
"save": "Save",
|
||||
"yes": "Yes",
|
||||
"no": "No"
|
||||
}
|
||||
|
||||
19
translation/en/settings.jsonc
Normal file
19
translation/en/settings.jsonc
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"no_changed": "Nothing was changed.",
|
||||
"saved": "Saved.",
|
||||
"failed": "Failed to fetch settings.",
|
||||
"need_restart": " Some settings require a restart to take effect.",
|
||||
"download_original_img": "Download original images.",
|
||||
"ex": "Use exhentai.org.",
|
||||
"mpv": "Fetch page data from Multi-Page Viewer.",
|
||||
"base": "Download location: ",
|
||||
"ua": "User Agent: ",
|
||||
"ua_now": "Use current browser's user agent.",
|
||||
"cookies": "Cookies: ",
|
||||
"enter_cookies": "Enter cookies here",
|
||||
"enter_new_cookies": "Enter new cookies here",
|
||||
"max_task_count": "Maximum number of parallel tasks: ",
|
||||
"max_retry_count": "Maximum retry count: ",
|
||||
"max_download_img_count": "Maximum number of parallel downloads of images: ",
|
||||
"save_dlg": "Do you want to save settings?"
|
||||
}
|
||||
@@ -1,3 +1,8 @@
|
||||
{
|
||||
"title": "EH 下载器"
|
||||
"title": "EH 下载器",
|
||||
"loading": "加载中…",
|
||||
"reload": "重新加载",
|
||||
"save": "保存",
|
||||
"yes": "是",
|
||||
"no": "否"
|
||||
}
|
||||
|
||||
19
translation/zh-cn/settings.jsonc
Normal file
19
translation/zh-cn/settings.jsonc
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"no_changed": "设置未更改,无需保存。",
|
||||
"saved": "已保存。",
|
||||
"failed": "获取设置失败。",
|
||||
"need_restart": "部分设置需要重启后才能生效。",
|
||||
"download_original_img": "下载原始画质的图片。",
|
||||
"ex": "使用exhentai.org。",
|
||||
"mpv": "从Multi-Page Viewer获取页面数据。",
|
||||
"base": "下载位置:",
|
||||
"ua": "用户代理(User Agent):",
|
||||
"ua_now": "使用当前浏览器的用户代理",
|
||||
"cookies": "Cookies:",
|
||||
"enter_cookies": "在此输入Cookies",
|
||||
"enter_new_cookies": "在此输入新的Cookies",
|
||||
"max_task_count": "最大并行任务数:",
|
||||
"max_retry_count": "最大重试次数:",
|
||||
"max_download_img_count": "最大图片并行下载数:",
|
||||
"save_dlg": "是否保存设置?"
|
||||
}
|
||||
Reference in New Issue
Block a user