Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 更新 偏好设置-历史记录 国际化 #556

Merged
merged 4 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/Update/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const Update = () => {
useMount(() => {
// 监听更新事件
listen<boolean>(LISTEN_KEY.UPDATE_APP, () => {
check(true);

messageApi.open({
key: MESSAGE_KEY,
type: "loading",
Expand Down
22 changes: 21 additions & 1 deletion src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,34 @@
"history": {
"history": {
"title": "History",
"button": {
"goto_delete": "Delete History",
"confirm_delete": "Confirm",
"cancel_delete": "Cancel"
},
"label": {
"duration": "Retention Duration",
"duration_unit": {
"day": "Day",
"week": "Week",
"month": "Month",
"year": "Year"
}
},
"delete_title": "Delete History",
"time_range": "Time Range",
"time_range_opt": {
"last_hour": "Last 1 Hour",
"last_24_hours": "Last 24 Hours",
"last_7_days": "Last 7 Days",
"last_30_days": "Last 30 Days",
"unlimited": "Unlimited",
"custom": "Custom"
},
"include_favorite": "Delete Favorites"
},
"hints": {
"duration": "Enter 0 to keep permanently, favorites will be retained when auto-deleting",
"delete_success": "Successfully Deleted"
}
}
},
Expand Down
22 changes: 21 additions & 1 deletion src/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,34 @@
"history": {
"history": {
"title": "履歴",
"button": {
"goto_delete": "履歴を削除",
"confirm_delete": "確認",
"cancel_delete": "キャンセル"
},
"label": {
"duration": "保持期間",
"duration_unit": {
"day": "日",
"week": "週",
"month": "月",
"year": "年"
}
},
"delete_title": "履歴を削除",
"time_range": "時間範囲",
"time_range_opt": {
"last_hour": "過去 1 時間",
"last_24_hours": "過去 24 時間",
"last_7_days": "過去 7 日間",
"last_30_days": "過去 30 日間",
"unlimited": "無制限",
"custom": "カスタム"
},
"include_favorite": "お気に入りも削除"
},
"hints": {
"duration": "0 を入力すると永久保存され、削除時にお気に入りが保持されます",
"delete_success": "削除が成功しました"
}
}
},
Expand Down
22 changes: 21 additions & 1 deletion src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,34 @@
"history": {
"history": {
"title": "历史记录",
"button": {
"goto_delete": "删除历史记录",
"confirm_delete": "确定",
"cancel_delete": "取消"
},
"label": {
"duration": "保留时长",
"duration_unit": {
"day": "天",
"week": "周",
"month": "月",
"year": "年"
}
},
"delete_title": "删除历史记录",
"time_range": "时间范围",
"time_range_opt": {
"last_hour": "过去 1 小时",
"last_24_hours": "过去 24 小时",
"last_7_days": "过去 7 天",
"last_30_days": "过去 30 天",
"unlimited": "时间不限",
"custom": "自定义"
},
"include_favorite": "删除收藏"
},
"hints": {
"duration": "输入 0 则表示永久保留,自动删除时会保留收藏",
"delete_success": "删除成功"
}
}
},
Expand Down
24 changes: 22 additions & 2 deletions src/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,35 @@
},
"history": {
"history": {
"title": "歷史紀錄",
"title": "歷史記錄",
"button": {
"goto_delete": "刪除歷史記錄",
"confirm_delete": "確定",
"cancel_delete": "取消"
},
"label": {
"duration": "保留時長",
"duration_unit": {
"day": "天",
"week": "週",
"month": "月",
"year": "年"
}
},
"delete_title": "刪除歷史記錄",
"time_range": "時間範圍",
"time_range_opt": {
"last_hour": "過去 1 小時",
"last_24_hours": "過去 24 小時",
"last_7_days": "過去 7 天",
"last_30_days": "過去 30 天",
"unlimited": "時間不限",
"custom": "自定義"
},
"include_favorite": "刪除收藏"
},
"hints": {
"duration": "輸入 0 表示永久保留,收藏在自動刪除時將保留",
"delete_success": "刪除成功"
}
}
},
Expand Down
33 changes: 20 additions & 13 deletions src/pages/History/components/Delete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,33 @@ const Delete = () => {
const timeRange = Form.useWatch("timeRange", form);
const [deleting, { setTrue, setFalse }] = useBoolean();

const { t } = useTranslation();

useEffect(form.resetFields, [open]);

const rangeOptions: DefaultOptionType[] = [
{
label: "过去 1 小时",
label: t("preference.history.history.label.time_range_opt.last_hour"),
value: 1,
},
{
label: "过去 1 天",
label: t("preference.history.history.label.time_range_opt.last_24_hours"),
value: 24,
},
{
label: "过去 7 天",
label: t("preference.history.history.label.time_range_opt.last_7_days"),
value: 7 * 24,
},
{
label: "过去 30 天",
label: t("preference.history.history.label.time_range_opt.last_30_days"),
value: 30 * 24,
},
{
label: "时间不限",
label: t("preference.history.history.label.time_range_opt.unlimited"),
value: 0,
},
{
label: "自定义",
label: t("preference.history.history.label.time_range_opt.custom"),
value: -1,
},
];
Expand Down Expand Up @@ -93,19 +95,19 @@ const Delete = () => {

toggle();
setFalse();
message.success("删除成功");
message.success(t("preference.history.history.hints.delete_success"));
emit(LISTEN_KEY.REFRESH_CLIPBOARD_LIST);
};

return (
<>
<Button block danger icon={<DeleteOutlined />} onClick={toggle}>
删除历史记录
{t("preference.history.history.button.goto_delete")}
</Button>

<Drawer
open={open}
title="删除历史记录"
title={t("preference.history.history.label.delete_title")}
width="100%"
closable={false}
classNames={{
Expand All @@ -115,11 +117,11 @@ const Delete = () => {
footer={
<Space>
<Button disabled={deleting} onClick={toggle}>
取消
{t("preference.history.history.button.cancel_delete")}
</Button>

<Button type="primary" loading={deleting} onClick={onSubmit}>
确定
{t("preference.history.history.button.confirm_delete")}
</Button>
</Space>
}
Expand All @@ -132,7 +134,10 @@ const Delete = () => {
}}
>
<Space>
<Form.Item name="timeRange" label="时间范围">
<Form.Item
name="timeRange"
label={t("preference.history.history.label.time_range")}
>
<EcoSelect options={rangeOptions} />
</Form.Item>

Expand All @@ -147,7 +152,9 @@ const Delete = () => {
</Space>

<Form.Item name="deleteFavorite" valuePropName="checked">
<Checkbox>删除收藏</Checkbox>
<Checkbox>
{t("preference.history.history.label.include_favorite")}
</Checkbox>
</Form.Item>
</Form>
</Drawer>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/History/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const History = () => {
<ProList header={t("preference.history.history.title")} footer={<Delete />}>
<ProListItem
title={t("preference.history.history.label.duration")}
description={"输入 0 则表示永久保留,自动删除时会保留收藏"}
description={t("preference.history.history.hints.duration")}
>
<InputNumber
min={0}
Expand Down