Skip to content

Commit 1edb9e6

Browse files
authored
feat: update i18n for zh-hans (#4488)
* chore:memo filter support i18n for zh-hans * feat: restore addFilter method value field in StatisticsView.tsx * chore: change getFilterDisplayText for i18n * chore: add string type in utils/i18n * feat: using switch to avoid change TranslationType * feat: eslint check * feat: eslint fix
1 parent 690f28b commit 1edb9e6

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

web/src/components/MemoFilters.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import { CalendarIcon, CheckCircleIcon, CodeIcon, EyeIcon, HashIcon, LinkIcon, S
33
import { useEffect } from "react";
44
import { useSearchParams } from "react-router-dom";
55
import { FilterFactor, getMemoFilterKey, MemoFilter, stringifyFilters, useMemoFilterStore } from "@/store/v1";
6+
import { useTranslate } from "@/utils/i18n";
67

78
const MemoFilters = () => {
9+
const t = useTranslate();
810
const [, setSearchParams] = useSearchParams();
911
const memoFilterStore = useMemoFilterStore();
1012
const filters = memoFilterStore.filters;
@@ -22,7 +24,17 @@ const MemoFilters = () => {
2224
return filter.value;
2325
}
2426
if (filter.factor.startsWith("property.")) {
25-
return filter.factor.replace("property.", "");
27+
const factorLabel = filter.factor.replace("property.", "");
28+
switch (factorLabel) {
29+
case "hasLink":
30+
return t("filters.has-link");
31+
case "hasCode":
32+
return t("filters.has-code");
33+
case "hasTaskList":
34+
return t("filters.has-task-list");
35+
default:
36+
return factorLabel;
37+
}
2638
}
2739
return filter.factor;
2840
};

web/src/locales/en.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,5 +408,10 @@
408408
"official-website": "Official Website",
409409
"blogs": "Blogs",
410410
"documents": "Documents"
411+
},
412+
"filters": {
413+
"has-link": "hasLink",
414+
"has-task-list": "hasTaskList",
415+
"has-code": "hasCode"
411416
}
412-
}
417+
}

web/src/locales/zh-Hans.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,5 +392,10 @@
392392
"official-website": "官网",
393393
"blogs": "博客",
394394
"documents": "文档"
395+
},
396+
"filters": {
397+
"has-link": "有链接",
398+
"has-task-list": "有待办",
399+
"has-code": "有代码"
395400
}
396-
}
401+
}

0 commit comments

Comments
 (0)