Compare commits

..

No commits in common. "4e99ee0c33849d7a0bddda193321aa09881cf917" and "e592c7044b5b95509eeffe6e85e6e2f526137b65" have entirely different histories.

8 changed files with 14 additions and 127 deletions

View File

@ -425,79 +425,5 @@
"television": "Television", "television": "Television",
"radio": "Radio", "radio": "Radio",
"field_recording": "Field Recording", "field_recording": "Field Recording",
"scream": "Scream", "scream": "Scream"
"sodeling": "Sodeling",
"chird": "Chird",
"change_ringing": "Change Ringing",
"shofar": "Shofar",
"liquid": "Liquid",
"splash": "Splash",
"slosh": "Slosh",
"squish": "Squish",
"drip": "Drip",
"pour": "Pour",
"trickle": "Trickle",
"gush": "Gush",
"fill": "Fill",
"spray": "Spray",
"pump": "Pump",
"stir": "Stir",
"boiling": "Boiling",
"sonar": "Sonar",
"arrow": "Arrow",
"whoosh": "Whoosh",
"thump": "Thump",
"thunk": "Thunk",
"electronic_tuner": "Electronic Tuner",
"effects_unit": "Effects Unit",
"chorus_effect": "Chorus Effect",
"basketball_bounce": "Basketball Bounce",
"bang": "Bang",
"slap": "Slap",
"whack": "Whack",
"smash": "Smash",
"breaking": "Breaking",
"bouncing": "Bouncing",
"whip": "Whip",
"flap": "Flap",
"scratch": "Scratch",
"scrape": "Scrape",
"rub": "Rub",
"roll": "Roll",
"crushing": "Crushing",
"crumpling": "Crumpling",
"tearing": "Tearing",
"beep": "Beep",
"ping": "Ping",
"ding": "Ding",
"clang": "Clang",
"squeal": "Squeal",
"creak": "Creak",
"rustle": "Rustle",
"whir": "Whir",
"clatter": "Clatter",
"sizzle": "Sizzle",
"clicking": "Clicking",
"clickety_clack": "Clickety Clack",
"rumble": "Rumble",
"plop": "Plop",
"hum": "Hum",
"zing": "Zing",
"boing": "Boing",
"crunch": "Crunch",
"sine_wave": "Sine Wave",
"harmonic": "Harmonic",
"chirp_tone": "Chirp Tone",
"pulse": "Pulse",
"inside": "Inside",
"outside": "Outside",
"reverberation": "Reverberation",
"echo": "Echo",
"noise": "Noise",
"mains_hum": "Mains Hum",
"distortion": "Distortion",
"sidetone": "Sidetone",
"cacophony": "Cacophony",
"throbbing": "Throbbing",
"vibration": "Vibration"
} }

View File

@ -150,7 +150,7 @@ export default function SearchThumbnail({
.filter( .filter(
(item) => item !== undefined && !item.includes("-verified"), (item) => item !== undefined && !item.includes("-verified"),
) )
.map((text) => getTranslatedLabel(text, searchResult.data.type)) .map((text) => getTranslatedLabel(text))
.sort() .sort()
.join(", ") .join(", ")
.replaceAll("-verified", "")} .replaceAll("-verified", "")}

View File

@ -34,7 +34,6 @@ const localeMap: Record<string, () => Promise<Locale>> = {
sk: () => import("date-fns/locale/sk").then((module) => module.sk), sk: () => import("date-fns/locale/sk").then((module) => module.sk),
"yue-Hant": () => "yue-Hant": () =>
import("date-fns/locale/zh-HK").then((module) => module.zhHK), import("date-fns/locale/zh-HK").then((module) => module.zhHK),
lt: () => import("date-fns/locale/lt").then((module) => module.lt),
th: () => import("date-fns/locale/th").then((module) => module.th), th: () => import("date-fns/locale/th").then((module) => module.th),
ca: () => import("date-fns/locale/ca").then((module) => module.ca), ca: () => import("date-fns/locale/ca").then((module) => module.ca),
}; };

View File

@ -10,17 +10,14 @@ export const supportedLanguageKeys = [
"ro", "ro",
"nl", "nl",
"nb-NO", "nb-NO",
"sv",
"zh-CN", "zh-CN",
"yue-Hant", "yue-Hant",
"ja",
"vi", "vi",
"th", "th",
"he", "he",
"ru", "ru",
"tr", "tr",
"pl", "pl",
"lt",
"uk", "uk",
"cs", "cs",
"hu", "hu",

View File

@ -29,8 +29,6 @@ export type SearchSortType =
| "score_desc" | "score_desc"
| "relevance"; | "relevance";
export type EventType = "object" | "audio" | "manual";
export type SearchResult = { export type SearchResult = {
id: string; id: string;
camera: string; camera: string;
@ -56,7 +54,7 @@ export type SearchResult = {
box: number[]; box: number[];
area: number; area: number;
ratio: number; ratio: number;
type: EventType; type: "object" | "audio" | "manual";
description?: string; description?: string;
average_estimated_speed: number; average_estimated_speed: number;
velocity_angle: number; velocity_angle: number;

View File

@ -1,29 +1,11 @@
import i18n, { t } from "i18next"; import i18n, { t } from "i18next";
import { initReactI18next } from "react-i18next"; import { initReactI18next } from "react-i18next";
import HttpBackend from "i18next-http-backend"; import HttpBackend from "i18next-http-backend";
import { EventType } from "@/types/search";
export const getTranslatedLabel = ( export const getTranslatedLabel = (label: string) => {
label: string,
type: EventType = "object",
) => {
if (!label) return ""; if (!label) return "";
if (type === "manual") return label; return t(`${label.replace(/\s+/g, "_").toLowerCase()}`, { ns: "objects" });
const normalize = (s: string) =>
s
.trim()
.replace(/[-'\s]+/g, "_")
.replace(/__+/g, "_")
.replace(/^_+|_+$/g, "")
.toLowerCase();
const key = normalize(label);
const ns = type === "audio" ? "audio" : "objects";
return t(key, { ns });
}; };
i18n i18n

View File

@ -11,7 +11,7 @@ import {
TooltipTrigger, TooltipTrigger,
} from "@/components/ui/tooltip"; } from "@/components/ui/tooltip";
import { TooltipPortal } from "@radix-ui/react-tooltip"; import { TooltipPortal } from "@radix-ui/react-tooltip";
import { EventType, SearchResult } from "@/types/search"; import { SearchResult } from "@/types/search";
import ImageLoadingIndicator from "@/components/indicators/ImageLoadingIndicator"; import ImageLoadingIndicator from "@/components/indicators/ImageLoadingIndicator";
import useImageLoaded from "@/hooks/use-image-loaded"; import useImageLoaded from "@/hooks/use-image-loaded";
import ActivityIndicator from "@/components/indicators/activity-indicator"; import ActivityIndicator from "@/components/indicators/activity-indicator";
@ -110,8 +110,7 @@ export default function ExploreView({
key={label} key={label}
searchResults={filteredEvents} searchResults={filteredEvents}
isValidating={isValidating} isValidating={isValidating}
label={label} objectType={label}
labelType={filteredEvents[0]?.data?.type || "object"}
setSearchDetail={setSearchDetail} setSearchDetail={setSearchDetail}
mutate={mutate} mutate={mutate}
setSimilaritySearch={setSimilaritySearch} setSimilaritySearch={setSimilaritySearch}
@ -123,8 +122,7 @@ export default function ExploreView({
} }
type ThumbnailRowType = { type ThumbnailRowType = {
label: string; objectType: string;
labelType: EventType;
searchResults?: SearchResult[]; searchResults?: SearchResult[];
isValidating: boolean; isValidating: boolean;
setSearchDetail: (search: SearchResult | undefined) => void; setSearchDetail: (search: SearchResult | undefined) => void;
@ -134,8 +132,7 @@ type ThumbnailRowType = {
}; };
function ThumbnailRow({ function ThumbnailRow({
label, objectType,
labelType,
searchResults, searchResults,
isValidating, isValidating,
setSearchDetail, setSearchDetail,
@ -156,7 +153,7 @@ function ThumbnailRow({
return ( return (
<div className="rounded-lg bg-background_alt p-2 md:px-4"> <div className="rounded-lg bg-background_alt p-2 md:px-4">
<div className="flex flex-row items-center text-lg smart-capitalize"> <div className="flex flex-row items-center text-lg smart-capitalize">
{getTranslatedLabel(label, labelType)} {getTranslatedLabel(objectType)}
{searchResults && ( {searchResults && (
<span className="ml-3 text-sm text-secondary-foreground"> <span className="ml-3 text-sm text-secondary-foreground">
{t("trackedObjectsCount", { {t("trackedObjectsCount", {
@ -184,7 +181,7 @@ function ThumbnailRow({
))} ))}
<div <div
className="flex cursor-pointer items-center justify-center" className="flex cursor-pointer items-center justify-center"
onClick={() => handleSearch(label)} onClick={() => handleSearch(objectType)}
> >
<Tooltip> <Tooltip>
<TooltipTrigger> <TooltipTrigger>
@ -195,9 +192,7 @@ function ThumbnailRow({
</TooltipTrigger> </TooltipTrigger>
<TooltipPortal> <TooltipPortal>
<TooltipContent> <TooltipContent>
{t("exploreMore", { {t("exploreMore", { label: getTranslatedLabel(objectType) })}
label: getTranslatedLabel(label, labelType),
})}
</TooltipContent> </TooltipContent>
</TooltipPortal> </TooltipPortal>
</Tooltip> </Tooltip>

View File

@ -100,12 +100,7 @@ export default function CameraSettingsView({
const alertsLabels = useMemo(() => { const alertsLabels = useMemo(() => {
return cameraConfig?.review.alerts.labels return cameraConfig?.review.alerts.labels
? cameraConfig.review.alerts.labels ? cameraConfig.review.alerts.labels
.map((label) => .map((label) => getTranslatedLabel(label))
getTranslatedLabel(
label,
cameraConfig?.audio?.listen?.includes(label) ? "audio" : "object",
),
)
.join(", ") .join(", ")
: ""; : "";
}, [cameraConfig]); }, [cameraConfig]);
@ -113,12 +108,7 @@ export default function CameraSettingsView({
const detectionsLabels = useMemo(() => { const detectionsLabels = useMemo(() => {
return cameraConfig?.review.detections.labels return cameraConfig?.review.detections.labels
? cameraConfig.review.detections.labels ? cameraConfig.review.detections.labels
.map((label) => .map((label) => getTranslatedLabel(label))
getTranslatedLabel(
label,
cameraConfig?.audio?.listen?.includes(label) ? "audio" : "object",
),
)
.join(", ") .join(", ")
: ""; : "";
}, [cameraConfig]); }, [cameraConfig]);