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

chore: update i18n for shortcut filter #270

Merged
merged 5 commits into from
Oct 8, 2022
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
12 changes: 8 additions & 4 deletions web/src/components/CreateShortcutDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,17 @@ interface MemoFilterInputerProps {

const MemoFilterInputer: React.FC<MemoFilterInputerProps> = (props: MemoFilterInputerProps) => {
const { index, filter, handleFilterChange, handleFilterRemove } = props;
const { t } = useTranslation();
const [value, setValue] = useState<string>(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 };
});
Expand Down Expand Up @@ -242,7 +246,7 @@ const MemoFilterInputer: React.FC<MemoFilterInputerProps> = (props: MemoFilterIn
/>
<Selector
className="operator-selector"
dataSource={Object.values(filterConsts[type as FilterType].operators)}
dataSource={operatorDataSource}
value={filter.value.operator}
handleValueChanged={handleOperatorChange}
/>
Expand All @@ -256,7 +260,7 @@ const MemoFilterInputer: React.FC<MemoFilterInputerProps> = (props: MemoFilterIn
}}
/>
) : (
<Selector className="value-selector" dataSource={dataSource} value={value} handleValueChanged={handleValueChange} />
<Selector className="value-selector" dataSource={valueDataSource} value={value} handleValueChanged={handleValueChange} />
)}
<Icon.X className="remove-btn" onClick={handleRemoveBtnClick} />
</div>
Expand Down
8 changes: 6 additions & 2 deletions web/src/components/Dialog/CommonDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useTranslation } from "react-i18next";
import Icon from "../Icon";
import { generateDialog } from "./BaseDialog";
import "../../less/common-dialog.less";
Expand All @@ -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: Props) => {
const { t } = useTranslation();
const { title, content, destroy, closeBtnText, confirmBtnText, onClose, onConfirm, style } = {
...defaultProps,
closeBtnText: t(defaultProps.closeBtnText),
confirmBtnText: t(defaultProps.confirmBtnText),
...props,
};

Expand Down
6 changes: 3 additions & 3 deletions web/src/components/ResourcesDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ const ResourcesDialog: React.FC<Props> = (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 () => {
Expand Down
16 changes: 8 additions & 8 deletions web/src/helpers/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
],
Expand All @@ -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",
},
],
Expand All @@ -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",
},
],
Expand Down
21 changes: 18 additions & 3 deletions web/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -142,4 +157,4 @@
"copied": "Copied",
"succeed-copy-content": "Succeed to copy content to clipboard."
}
}
}
21 changes: 18 additions & 3 deletions web/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
"repeat-new-password": "重复新密码",
"username": "用户名",
"save": "保存",
"close": "关闭",
"cancel": "退出",
"create": "创建",
"change": "修改",
"confirm": "确定",
"reset": "重置",
"language": "语言",
"version": "版本",
Expand Down Expand Up @@ -58,7 +60,10 @@
"fetching-data": "请求数据中...",
"upload": "上传",
"preview": "预览",
"copy-link": "拷贝链接"
"copy-link": "拷贝链接",
"delete-resource": "删除资源",
"warning-text": "确定删除这个资源么?此操作不可逆❗️",
"linked-amount": "链接的 Memo 数量"
},
"archived": {
"archived-memos": "已归档的 Memo",
Expand Down Expand Up @@ -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 `来创建标签"
Expand Down Expand Up @@ -142,4 +157,4 @@
"copied": "Copied",
"succeed-copy-content": "Succeed to copy content to clipboard."
}
}
}