diff --git a/web/src/components/CreateShortcutDialog.tsx b/web/src/components/CreateShortcutDialog.tsx index c801cd14..a4051e8b 100644 --- a/web/src/components/CreateShortcutDialog.tsx +++ b/web/src/components/CreateShortcutDialog.tsx @@ -161,13 +161,17 @@ interface MemoFilterInputerProps { const MemoFilterInputer: React.FC = (props: MemoFilterInputerProps) => { const { index, filter, handleFilterChange, handleFilterRemove } = props; + const { t } = useTranslation(); const [value, setValue] = useState(filter.value.value); const tags = Array.from(memoService.getState().tags); const { type } = filter; - const dataSource = + + const operatorDataSource = Object.values(filterConsts[type as FilterType].operators).map(({ text, value }) => ({ text: t(text), value })); + + const valueDataSource = type === "TYPE" - ? filterConsts["TYPE"].values + ? filterConsts["TYPE"].values.map(({ text, value }) => ({ text: t(text), value })) : tags.sort().map((t) => { return { text: t, value: t }; }); @@ -242,7 +246,7 @@ const MemoFilterInputer: React.FC = (props: MemoFilterIn /> @@ -256,7 +260,7 @@ const MemoFilterInputer: React.FC = (props: MemoFilterIn }} /> ) : ( - + )} diff --git a/web/src/components/Dialog/CommonDialog.tsx b/web/src/components/Dialog/CommonDialog.tsx index 3975fc51..50d4bfe4 100644 --- a/web/src/components/Dialog/CommonDialog.tsx +++ b/web/src/components/Dialog/CommonDialog.tsx @@ -1,3 +1,4 @@ +import { useTranslation } from "react-i18next"; import Icon from "../Icon"; import { generateDialog } from "./BaseDialog"; import "../../less/common-dialog.less"; @@ -18,15 +19,18 @@ const defaultProps = { title: "", content: "", style: "info", - closeBtnText: "Close", - confirmBtnText: "Confirm", + closeBtnText: "common.close", + confirmBtnText: "common.confirm", onClose: () => null, onConfirm: () => null, }; const CommonDialog: React.FC = (props: Props) => { + const { t } = useTranslation(); const { title, content, destroy, closeBtnText, confirmBtnText, onClose, onConfirm, style } = { ...defaultProps, + closeBtnText: t(defaultProps.closeBtnText), + confirmBtnText: t(defaultProps.confirmBtnText), ...props, }; diff --git a/web/src/components/ResourcesDialog.tsx b/web/src/components/ResourcesDialog.tsx index 33148758..135ec90c 100644 --- a/web/src/components/ResourcesDialog.tsx +++ b/web/src/components/ResourcesDialog.tsx @@ -104,13 +104,13 @@ const ResourcesDialog: React.FC = (props: Props) => { }; const handleDeleteResourceBtnClick = (resource: Resource) => { - let warningText = "Are you sure to delete this resource? THIS ACTION IS IRREVERSIABLE.❗️"; + let warningText = t("resources.warning-text"); if (resource.linkedMemoAmount > 0) { - warningText = warningText + `\nLinked memo amount: ${resource.linkedMemoAmount}`; + warningText = warningText + `\n${t("resources.linked-amount")}: ${resource.linkedMemoAmount}`; } showCommonDialog({ - title: `Delete Resource`, + title: t("resources.delete-resource"), content: warningText, style: "warning", onConfirm: async () => { diff --git a/web/src/helpers/filter.ts b/web/src/helpers/filter.ts index 7865d938..039c1e6f 100644 --- a/web/src/helpers/filter.ts +++ b/web/src/helpers/filter.ts @@ -11,11 +11,11 @@ export const filterConsts = { value: "TAG", operators: [ { - text: "Contains", + text: "shortcut-list.operator.contains", value: "CONTAIN", }, { - text: "Does not contain", + text: "shortcut-list.operator.not-contains", value: "NOT_CONTAIN", }, ], @@ -25,21 +25,21 @@ export const filterConsts = { value: "TYPE", operators: [ { - text: "Is", + text: "shortcut-list.operator.is", value: "IS", }, { - text: "Is not", + text: "shortcut-list.operator.is-not", value: "IS_NOT", }, ], values: [ { - text: "No tags", + text: "shortcut-list.value.not-tagged", value: "NOT_TAGGED", }, { - text: "Has links", + text: "shortcut-list.value.linked", value: "LINKED", }, ], @@ -49,11 +49,11 @@ export const filterConsts = { value: "TEXT", operators: [ { - text: "Contain", + text: "shortcut-list.operator.contains", value: "CONTAIN", }, { - text: "Does not contain", + text: "shortcut-list.operator.not-contains", value: "NOT_CONTAIN", }, ], diff --git a/web/src/locales/en.json b/web/src/locales/en.json index ce416022..c99b3f7d 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -7,9 +7,11 @@ "repeat-new-password": "Repeat the new password", "username": "Username", "save": "Save", + "close": "Close", "cancel": "Cancel", "create": "Create", "change": "Change", + "confirm": "Confirm", "reset": "Reset", "language": "Language", "version": "Version", @@ -58,7 +60,10 @@ "fetching-data": "fetching data...", "upload": "Upload", "preview": "Preview", - "copy-link": "Copy Link" + "copy-link": "Copy Link", + "delete-resource": "Delete Resource", + "warning-text": "Are you sure to delete this resource? THIS ACTION IS IRREVERSIABLE❗️", + "linked-amount": "Linked memo amount" }, "archived": { "archived-memos": "Archived Memos", @@ -91,7 +96,17 @@ "new-filter": "New Filter", "eligible-memo": "eligible memo", "fill-previous": "Please fill in previous filter value", - "title-required": "Title is required" + "title-required": "Title is required", + "operator": { + "contains": "Contains", + "not-contains": "Does not contain", + "is": "Is", + "is-not": "Is Not" + }, + "value": { + "not-tagged": "No tags", + "linked": "Has links" + } }, "tag-list": { "tip-text": "Enter `#tag ` to create" @@ -142,4 +157,4 @@ "copied": "Copied", "succeed-copy-content": "Succeed to copy content to clipboard." } -} +} \ No newline at end of file diff --git a/web/src/locales/zh.json b/web/src/locales/zh.json index f9bb38db..a9c1386f 100644 --- a/web/src/locales/zh.json +++ b/web/src/locales/zh.json @@ -7,9 +7,11 @@ "repeat-new-password": "重复新密码", "username": "用户名", "save": "保存", + "close": "关闭", "cancel": "退出", "create": "创建", "change": "修改", + "confirm": "确定", "reset": "重置", "language": "语言", "version": "版本", @@ -58,7 +60,10 @@ "fetching-data": "请求数据中...", "upload": "上传", "preview": "预览", - "copy-link": "拷贝链接" + "copy-link": "拷贝链接", + "delete-resource": "删除资源", + "warning-text": "确定删除这个资源么?此操作不可逆❗️", + "linked-amount": "链接的 Memo 数量" }, "archived": { "archived-memos": "已归档的 Memo", @@ -91,7 +96,17 @@ "new-filter": "新建过滤器", "eligible-memo": "符合条件的 memo", "fill-previous": "请填写之前的过滤值", - "title-required": "标题是必填项。" + "title-required": "标题是必填项。", + "operator": { + "contains": "包含", + "not-contains": "不包含", + "is": "是", + "is-not": "不是" + }, + "value": { + "not-tagged": "无标签", + "linked": "包含链接" + } }, "tag-list": { "tip-text": "输入`#tag `来创建标签" @@ -142,4 +157,4 @@ "copied": "Copied", "succeed-copy-content": "Succeed to copy content to clipboard." } -} +} \ No newline at end of file