Fix I18n audio labels (#20508)

* ensure i18n audio label keys are translated

don't assume they are in the objects namespace

* add missing audio labels

* Improve handling of label types

* simplify

* fixes

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
This commit is contained in:
Josh Hawkins
2025-10-15 13:02:08 -06:00
committed by GitHub
co-authored by Nicolas Mowen
parent e592c7044b
commit 75d7049b6d
6 changed files with 123 additions and 14 deletions
+12 -7
View File
@@ -11,7 +11,7 @@ import {
TooltipTrigger,
} from "@/components/ui/tooltip";
import { TooltipPortal } from "@radix-ui/react-tooltip";
import { SearchResult } from "@/types/search";
import { EventType, SearchResult } from "@/types/search";
import ImageLoadingIndicator from "@/components/indicators/ImageLoadingIndicator";
import useImageLoaded from "@/hooks/use-image-loaded";
import ActivityIndicator from "@/components/indicators/activity-indicator";
@@ -110,7 +110,8 @@ export default function ExploreView({
key={label}
searchResults={filteredEvents}
isValidating={isValidating}
objectType={label}
label={label}
labelType={filteredEvents[0]?.data?.type || "object"}
setSearchDetail={setSearchDetail}
mutate={mutate}
setSimilaritySearch={setSimilaritySearch}
@@ -122,7 +123,8 @@ export default function ExploreView({
}
type ThumbnailRowType = {
objectType: string;
label: string;
labelType: EventType;
searchResults?: SearchResult[];
isValidating: boolean;
setSearchDetail: (search: SearchResult | undefined) => void;
@@ -132,7 +134,8 @@ type ThumbnailRowType = {
};
function ThumbnailRow({
objectType,
label,
labelType,
searchResults,
isValidating,
setSearchDetail,
@@ -153,7 +156,7 @@ function ThumbnailRow({
return (
<div className="rounded-lg bg-background_alt p-2 md:px-4">
<div className="flex flex-row items-center text-lg smart-capitalize">
{getTranslatedLabel(objectType)}
{getTranslatedLabel(label, labelType)}
{searchResults && (
<span className="ml-3 text-sm text-secondary-foreground">
{t("trackedObjectsCount", {
@@ -181,7 +184,7 @@ function ThumbnailRow({
))}
<div
className="flex cursor-pointer items-center justify-center"
onClick={() => handleSearch(objectType)}
onClick={() => handleSearch(label)}
>
<Tooltip>
<TooltipTrigger>
@@ -192,7 +195,9 @@ function ThumbnailRow({
</TooltipTrigger>
<TooltipPortal>
<TooltipContent>
{t("exploreMore", { label: getTranslatedLabel(objectType) })}
{t("exploreMore", {
label: getTranslatedLabel(label, labelType),
})}
</TooltipContent>
</TooltipPortal>
</Tooltip>
+12 -2
View File
@@ -100,7 +100,12 @@ export default function CameraSettingsView({
const alertsLabels = useMemo(() => {
return cameraConfig?.review.alerts.labels
? cameraConfig.review.alerts.labels
.map((label) => getTranslatedLabel(label))
.map((label) =>
getTranslatedLabel(
label,
cameraConfig?.audio?.listen?.includes(label) ? "audio" : "object",
),
)
.join(", ")
: "";
}, [cameraConfig]);
@@ -108,7 +113,12 @@ export default function CameraSettingsView({
const detectionsLabels = useMemo(() => {
return cameraConfig?.review.detections.labels
? cameraConfig.review.detections.labels
.map((label) => getTranslatedLabel(label))
.map((label) =>
getTranslatedLabel(
label,
cameraConfig?.audio?.listen?.includes(label) ? "audio" : "object",
),
)
.join(", ")
: "";
}, [cameraConfig]);