From 581ca349c2ce8d4342f34c3ada645e630f5acbf6 Mon Sep 17 00:00:00 2001 From: ZhaiSoul <842607283@qq.com> Date: Sat, 15 Mar 2025 14:23:15 +0800 Subject: [PATCH] feat: add more search i18n keys --- web/public/locales/en/views/search.json | 29 ++++++++++++++++++++ web/public/locales/zh-CN/views/search.json | 29 ++++++++++++++++++++ web/src/components/input/InputWithTags.tsx | 31 ++++++++++++++++------ 3 files changed, 81 insertions(+), 8 deletions(-) diff --git a/web/public/locales/en/views/search.json b/web/public/locales/en/views/search.json index fbb43253e..ae363fdba 100644 --- a/web/public/locales/en/views/search.json +++ b/web/public/locales/en/views/search.json @@ -10,6 +10,27 @@ "filterActive": "Filters active" }, "filter": { + "label": { + "cameras": "Cameras", + "labels": "Labels", + "zones": "Zones", + "sub_labels": "Sub Labels", + "search_type": "Search Type", + "time_range": "Time Range", + "before": "Before", + "after": "After", + "min_score": "Min Score", + "max_score": "Max Score", + "min_speed": "Min Speed", + "max_speed": "Max Speed", + "recognized_license_plate": "Recognized License Plate", + "has_clip": "Has Clip", + "has_snapshot": "Has Snapshot" + }, + "searchType": { + "thumbnail": "Thumbnail", + "description": "Description" + }, "toast": { "error": { "beforeDateBeLaterAfter": "The 'before' date must be later than the 'after' date.", @@ -25,11 +46,19 @@ "desc": "Filters help you narrow down your search results. Here's how to use them in the input field:", "desc.step": "", "desc.example": "Example: cameras:front_door label:person before:01012024 time_range:3:00PM-4:00PM " + }, + "header": { + "currentFilterType": "Filter Values", + "noFilters": "Filters", + "activeFilters": "Active Filters" } }, "similaritySearch": { "title": "Similarity Search", "active": "Similarity search active", "clear": "Clear similarity search" + }, + "placeholder": { + "search": "Search..." } } \ No newline at end of file diff --git a/web/public/locales/zh-CN/views/search.json b/web/public/locales/zh-CN/views/search.json index 11e806844..76a7a942b 100644 --- a/web/public/locales/zh-CN/views/search.json +++ b/web/public/locales/zh-CN/views/search.json @@ -10,6 +10,27 @@ "filterActive": "筛选器已激活" }, "filter": { + "label": { + "cameras": "摄像机", + "labels": "标签", + "zones": "区域", + "sub_labels": "子标签", + "search_type": "搜索类型", + "time_range": "时间范围", + "before": "之前", + "after": "之后", + "min_score": "最低分数", + "max_score": "最高分数", + "min_speed": "最低速度", + "max_speed": "最高速度", + "recognized_license_plate": "识别的车牌", + "has_clip": "包含片段", + "has_snapshot": "包含快照" + }, + "searchType": { + "thumbnail": "缩略图", + "description": "描述" + }, "toast": { "error": { "beforeDateBeLaterAfter": "“之前”日期必须晚于“之后”日期。", @@ -25,11 +46,19 @@ "desc": "筛选器可帮助您缩小搜索范围。注意,目前还暂不支持中文搜索。以下是在输入字段中使用筛选器的方法:", "desc.step": "", "desc.example": "示例:cameras:front_door label:person before:01012024 time_range:3:00PM-4:00PM" + }, + "header": { + "currentFilterType": "筛选值", + "noFilters": "筛选条件", + "activeFilters": "激活的筛选项" } }, "similaritySearch": { "title": "相似搜索", "active": "相似搜索已激活", "clear": "清除相似搜索" + }, + "placeholder": { + "search": "搜索..." } } diff --git a/web/src/components/input/InputWithTags.tsx b/web/src/components/input/InputWithTags.tsx index 56fc6feb3..ce30a5d89 100644 --- a/web/src/components/input/InputWithTags.tsx +++ b/web/src/components/input/InputWithTags.tsx @@ -415,9 +415,15 @@ export default function InputWithTags({ filterType === "has_snapshot" || filterType === "is_submitted" ) { - return filterValues ? "Yes" : "No"; + return filterValues + ? t("button.yes", { ns: "common" }) + : t("button.no", { ns: "common" }); + } else if (filterType === "labels") { + return t(filterValues as string, { ns: "objects" }); + } else if (filterType === "search_type") { + return t("filter.searchType." + (filterValues as string)); } else { - return filterValues as string; + return (filterValues as string).replaceAll("_", " "); } } @@ -653,7 +659,7 @@ export default function InputWithTags({ onBlur={handleInputBlur} onKeyDown={handleInputKeyDown} className="text-md h-9 pr-32" - placeholder="Search..." + placeholder={t("placeholder.search")} />
{(search || Object.keys(filters).length > 0) && ( @@ -775,7 +781,7 @@ export default function InputWithTags({ )} {(Object.keys(filters).filter((key) => key !== "query").length > 0 || isSimilaritySearch) && ( - +
{isSimilaritySearch && ( @@ -799,8 +805,8 @@ export default function InputWithTags({ key={`${filterType}-${index}`} className="inline-flex items-center whitespace-nowrap rounded-full bg-green-100 px-2 py-0.5 text-sm capitalize text-green-800" > - {filterType.replaceAll("_", " ")}:{" "} - {value.replaceAll("_", " ")} + {t("filter.label." + filterType)}:{" "} + {formatFilterValues(filterType, value)}