Implement smart capitalization based on locale (#17860)

This commit is contained in:
Nicolas Mowen 2025-04-22 16:21:09 -06:00 committed by GitHub
parent b6e0e5698a
commit f9b2db4405
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
44 changed files with 95 additions and 71 deletions

View File

@ -6,12 +6,13 @@ import Sidebar from "@/components/navigation/Sidebar";
import { isDesktop, isMobile } from "react-device-detect"; import { isDesktop, isMobile } from "react-device-detect";
import Statusbar from "./components/Statusbar"; import Statusbar from "./components/Statusbar";
import Bottombar from "./components/navigation/Bottombar"; import Bottombar from "./components/navigation/Bottombar";
import { Suspense, lazy } from "react"; import React, { Suspense, lazy } from "react";
import { Redirect } from "./components/navigation/Redirect"; import { Redirect } from "./components/navigation/Redirect";
import { cn } from "./lib/utils"; import { cn } from "./lib/utils";
import { isPWA } from "./utils/isPWA"; import { isPWA } from "./utils/isPWA";
import ProtectedRoute from "@/components/auth/ProtectedRoute"; import ProtectedRoute from "@/components/auth/ProtectedRoute";
import { AuthProvider } from "@/context/auth-context"; import { AuthProvider } from "@/context/auth-context";
import { useTranslation } from "react-i18next";
const Live = lazy(() => import("@/pages/Live")); const Live = lazy(() => import("@/pages/Live"));
const Events = lazy(() => import("@/pages/Events")); const Events = lazy(() => import("@/pages/Events"));
@ -26,6 +27,13 @@ const Logs = lazy(() => import("@/pages/Logs"));
const AccessDenied = lazy(() => import("@/pages/AccessDenied")); const AccessDenied = lazy(() => import("@/pages/AccessDenied"));
function App() { function App() {
const { i18n } = useTranslation();
// Set the lang attribute on the html element when language changes
React.useEffect(() => {
document.documentElement.lang = i18n.language;
}, [i18n.language]);
return ( return (
<Providers> <Providers>
<AuthProvider> <AuthProvider>

View File

@ -222,7 +222,7 @@ export default function ExportCard({
<Skeleton className="absolute inset-0 aspect-video rounded-lg md:rounded-2xl" /> <Skeleton className="absolute inset-0 aspect-video rounded-lg md:rounded-2xl" />
)} )}
<div className="rounded-b-l pointer-events-none absolute inset-x-0 bottom-0 h-[20%] rounded-lg bg-gradient-to-t from-black/60 to-transparent md:rounded-2xl"> <div className="rounded-b-l pointer-events-none absolute inset-x-0 bottom-0 h-[20%] rounded-lg bg-gradient-to-t from-black/60 to-transparent md:rounded-2xl">
<div className="mx-3 flex h-full items-end justify-between pb-1 text-sm capitalize text-white"> <div className="mx-3 flex h-full items-end justify-between pb-1 text-sm text-white smart-capitalize">
{exportedRecording.name.replaceAll("_", " ")} {exportedRecording.name.replaceAll("_", " ")}
</div> </div>
</div> </div>

View File

@ -175,7 +175,7 @@ export default function ReviewCard({
<div className="font-extra-light text-xs">{formattedDate}</div> <div className="font-extra-light text-xs">{formattedDate}</div>
</div> </div>
</TooltipTrigger> </TooltipTrigger>
<TooltipContent className="capitalize"> <TooltipContent className="smart-capitalize">
{[ {[
...new Set([ ...new Set([
...(event.data.objects || []), ...(event.data.objects || []),

View File

@ -146,7 +146,7 @@ export default function SearchThumbnail({
</TooltipTrigger> </TooltipTrigger>
</div> </div>
<TooltipPortal> <TooltipPortal>
<TooltipContent className="capitalize"> <TooltipContent className="smart-capitalize">
{[searchResult.sub_label ?? objectLabel] {[searchResult.sub_label ?? objectLabel]
.filter( .filter(
(item) => item !== undefined && !item.includes("-verified"), (item) => item !== undefined && !item.includes("-verified"),

View File

@ -196,7 +196,7 @@ export function CameraGroupSelector({ className }: CameraGroupSelectorProps) {
</Button> </Button>
</TooltipTrigger> </TooltipTrigger>
<TooltipPortal> <TooltipPortal>
<TooltipContent className="capitalize" side="right"> <TooltipContent className="smart-capitalize" side="right">
{name} {name}
</TooltipContent> </TooltipContent>
</TooltipPortal> </TooltipPortal>
@ -847,7 +847,7 @@ export function CameraGroupEdit({
<FormControl key={camera}> <FormControl key={camera}>
<div className="flex items-center justify-between gap-1"> <div className="flex items-center justify-between gap-1">
<Label <Label
className="mx-2 w-full cursor-pointer capitalize text-primary" className="mx-2 w-full cursor-pointer text-primary smart-capitalize"
htmlFor={camera.replaceAll("_", " ")} htmlFor={camera.replaceAll("_", " ")}
> >
{camera.replaceAll("_", " ")} {camera.replaceAll("_", " ")}

View File

@ -62,7 +62,7 @@ export function CamerasFilterButton({
const trigger = ( const trigger = (
<Button <Button
className="flex items-center gap-2 capitalize" className="flex items-center gap-2 smart-capitalize"
aria-label={t("cameras.label")} aria-label={t("cameras.label")}
variant={selectedCameras?.length == undefined ? "default" : "select"} variant={selectedCameras?.length == undefined ? "default" : "select"}
size="sm" size="sm"
@ -172,7 +172,7 @@ export function CamerasFilterContent({
return ( return (
<div <div
key={name} key={name}
className="w-full cursor-pointer rounded-lg px-2 py-0.5 text-sm capitalize text-primary hover:bg-muted" className="w-full cursor-pointer rounded-lg px-2 py-0.5 text-sm text-primary smart-capitalize hover:bg-muted"
onClick={() => { onClick={() => {
setCurrentCameras([...conf.cameras]); setCurrentCameras([...conf.cameras]);
}} }}

View File

@ -16,7 +16,7 @@ export default function FilterSwitch({
return ( return (
<div className="flex items-center justify-between gap-1"> <div className="flex items-center justify-between gap-1">
<Label <Label
className={`mx-2 w-full cursor-pointer capitalize text-primary ${disabled ? "text-secondary-foreground" : ""}`} className={`mx-2 w-full cursor-pointer text-primary smart-capitalize ${disabled ? "text-secondary-foreground" : ""}`}
htmlFor={label} htmlFor={label}
> >
{label} {label}

View File

@ -126,7 +126,7 @@ export function GeneralFilterContent({
{["debug", "info", "warning", "error"].map((item) => ( {["debug", "info", "warning", "error"].map((item) => (
<div className="flex items-center justify-between" key={item}> <div className="flex items-center justify-between" key={item}>
<Label <Label
className="mx-2 w-full cursor-pointer capitalize text-primary" className="mx-2 w-full cursor-pointer text-primary smart-capitalize"
htmlFor={item} htmlFor={item}
> >
{item.replaceAll("_", " ")} {item.replaceAll("_", " ")}

View File

@ -354,7 +354,7 @@ function GeneralFilterButton({
variant={ variant={
selectedLabels?.length || selectedZones?.length ? "select" : "default" selectedLabels?.length || selectedZones?.length ? "select" : "default"
} }
className="flex items-center gap-2 capitalize" className="flex items-center gap-2 smart-capitalize"
aria-label={t("filter")} aria-label={t("filter")}
> >
<FaFilter <FaFilter

View File

@ -285,7 +285,7 @@ function GeneralFilterButton({
<Button <Button
size="sm" size="sm"
variant={selectedLabels?.length ? "select" : "default"} variant={selectedLabels?.length ? "select" : "default"}
className="flex items-center gap-2 capitalize" className="flex items-center gap-2 smart-capitalize"
aria-label={t("labels.label")} aria-label={t("labels.label")}
> >
<MdLabel <MdLabel
@ -457,7 +457,7 @@ function SortTypeButton({
? "select" ? "select"
: "default" : "default"
} }
className="flex items-center gap-2 capitalize" className="flex items-center gap-2 smart-capitalize"
aria-label={t("labels.label")} aria-label={t("labels.label")}
> >
<MdSort <MdSort

View File

@ -22,7 +22,7 @@ export function ZoneMaskFilterButton({
<Button <Button
size="sm" size="sm"
variant={selectedZoneMask?.length ? "select" : "default"} variant={selectedZoneMask?.length ? "select" : "default"}
className="flex items-center gap-2 capitalize" className="flex items-center gap-2 smart-capitalize"
aria-label={t("zoneMask.filterBy")} aria-label={t("zoneMask.filterBy")}
> >
<FaFilter <FaFilter
@ -96,7 +96,7 @@ export function GeneralFilterContent({
{["zone", "motion_mask", "object_mask"].map((item) => ( {["zone", "motion_mask", "object_mask"].map((item) => (
<div key={item} className="flex items-center justify-between"> <div key={item} className="flex items-center justify-between">
<Label <Label
className="mx-2 w-full cursor-pointer capitalize text-primary" className="mx-2 w-full cursor-pointer text-primary smart-capitalize"
htmlFor={item} htmlFor={item}
> >
{t( {t(

View File

@ -191,7 +191,7 @@ export function CombinedStorageGraph({
<TableBody> <TableBody>
{series.map((item) => ( {series.map((item) => (
<TableRow key={item.name}> <TableRow key={item.name}>
<TableCell className="flex flex-row items-center gap-2 font-medium capitalize"> <TableCell className="flex flex-row items-center gap-2 font-medium smart-capitalize">
{" "} {" "}
<div <div
className="size-3 rounded-md" className="size-3 rounded-md"

View File

@ -72,7 +72,7 @@ export function LogChip({ severity, onClickSeverity }: LogChipProps) {
return ( return (
<div className="min-w-16 lg:min-w-20"> <div className="min-w-16 lg:min-w-20">
<span <span
className={`rounded-md px-1 py-[1px] text-xs capitalize ${onClickSeverity ? "cursor-pointer" : ""} ${severityClassName}`} className={`rounded-md px-1 py-[1px] text-xs smart-capitalize ${onClickSeverity ? "cursor-pointer" : ""} ${severityClassName}`}
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();

View File

@ -816,7 +816,7 @@ export default function InputWithTags({
.map((value, index) => ( .map((value, index) => (
<span <span
key={`${filterType}-${index}`} 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" className="inline-flex items-center whitespace-nowrap rounded-full bg-green-100 px-2 py-0.5 text-sm text-green-800 smart-capitalize"
> >
{t("filter.label." + filterType)}:{" "} {t("filter.label." + filterType)}:{" "}
{filterType === "labels" {filterType === "labels"
@ -838,7 +838,7 @@ export default function InputWithTags({
: !(filterType == "event_id" && isSimilaritySearch) && ( : !(filterType == "event_id" && isSimilaritySearch) && (
<span <span
key={filterType} key={filterType}
className="inline-flex items-center whitespace-nowrap rounded-full bg-green-100 px-2 py-0.5 text-sm capitalize text-green-800" className="inline-flex items-center whitespace-nowrap rounded-full bg-green-100 px-2 py-0.5 text-sm text-green-800 smart-capitalize"
> >
{filterType === "event_id" {filterType === "event_id"
? t("trackedObjectId") ? t("trackedObjectId")

View File

@ -265,7 +265,7 @@ export default function LiveContextMenu({
<ContextMenuTrigger>{children}</ContextMenuTrigger> <ContextMenuTrigger>{children}</ContextMenuTrigger>
<ContextMenuContent> <ContextMenuContent>
<div className="flex flex-col items-start gap-1 py-1 pl-2"> <div className="flex flex-col items-start gap-1 py-1 pl-2">
<div className="text-md capitalize text-primary-variant"> <div className="text-md text-primary-variant smart-capitalize">
{camera.replaceAll("_", " ")} {camera.replaceAll("_", " ")}
</div> </div>
{preferredLiveMode == "jsmpeg" && isRestreamed && ( {preferredLiveMode == "jsmpeg" && isRestreamed && (

View File

@ -83,7 +83,7 @@ export default function CameraInfoDialog({
> >
<DialogContent> <DialogContent>
<DialogHeader> <DialogHeader>
<DialogTitle className="capitalize"> <DialogTitle className="smart-capitalize">
{t("cameras.info.cameraProbeInfo", { {t("cameras.info.cameraProbeInfo", {
camera: camera.name.replaceAll("_", " "), camera: camera.name.replaceAll("_", " "),
})} })}

View File

@ -288,7 +288,7 @@ export function ExportContent({
id={opt} id={opt}
value={opt} value={opt}
/> />
<Label className="cursor-pointer capitalize" htmlFor={opt}> <Label className="cursor-pointer smart-capitalize" htmlFor={opt}>
{isNaN(parseInt(opt)) {isNaN(parseInt(opt))
? opt == "timeline" ? opt == "timeline"
? t("export.time.fromTimeline") ? t("export.time.fromTimeline")

View File

@ -91,7 +91,7 @@ export default function FaceSelectionDialog({
)} )}
> >
<SelectorItem <SelectorItem
className="flex cursor-pointer gap-2 capitalize" className="flex cursor-pointer gap-2 smart-capitalize"
onClick={() => setNewFace(true)} onClick={() => setNewFace(true)}
> >
<LuPlus /> <LuPlus />
@ -100,7 +100,7 @@ export default function FaceSelectionDialog({
{faceNames.map((faceName) => ( {faceNames.map((faceName) => (
<SelectorItem <SelectorItem
key={faceName} key={faceName}
className="flex cursor-pointer gap-2 capitalize" className="flex cursor-pointer gap-2 smart-capitalize"
onClick={() => onTrainAttempt(faceName)} onClick={() => onTrainAttempt(faceName)}
> >
<LuScanFace /> <LuScanFace />

View File

@ -26,7 +26,7 @@ export default function MobileCameraDrawer({
<Drawer open={cameraDrawer} onOpenChange={setCameraDrawer}> <Drawer open={cameraDrawer} onOpenChange={setCameraDrawer}>
<DrawerTrigger asChild> <DrawerTrigger asChild>
<Button <Button
className="rounded-lg capitalize" className="rounded-lg smart-capitalize"
aria-label={t("menu.live.cameras.title")} aria-label={t("menu.live.cameras.title")}
size="sm" size="sm"
> >
@ -38,7 +38,7 @@ export default function MobileCameraDrawer({
{allCameras.map((cam) => ( {allCameras.map((cam) => (
<div <div
key={cam} key={cam}
className={`mx-4 w-full py-2 text-center capitalize ${cam == selected ? "rounded-lg bg-secondary" : ""}`} className={`mx-4 w-full py-2 text-center smart-capitalize ${cam == selected ? "rounded-lg bg-secondary" : ""}`}
onClick={() => { onClick={() => {
onSelectCamera(cam); onSelectCamera(cam);
setCameraDrawer(false); setCameraDrawer(false);

View File

@ -324,7 +324,7 @@ export default function MobileReviewSettingsDrawer({
> >
<DrawerTrigger asChild> <DrawerTrigger asChild>
<Button <Button
className="rounded-lg capitalize" className="rounded-lg smart-capitalize"
aria-label={t("filters")} aria-label={t("filters")}
variant={ variant={
filter?.labels || filter?.after || filter?.zones filter?.labels || filter?.after || filter?.zones

View File

@ -23,7 +23,7 @@ export default function MobileTimelineDrawer({
<Drawer open={drawer} onOpenChange={setDrawer}> <Drawer open={drawer} onOpenChange={setDrawer}>
<DrawerTrigger asChild> <DrawerTrigger asChild>
<Button <Button
className="rounded-lg capitalize" className="rounded-lg smart-capitalize"
aria-label="Select timeline or events list" aria-label="Select timeline or events list"
size="sm" size="sm"
> >
@ -32,7 +32,7 @@ export default function MobileTimelineDrawer({
</DrawerTrigger> </DrawerTrigger>
<DrawerContent className="mx-1 flex max-h-[75dvh] flex-col items-center gap-2 overflow-hidden rounded-t-2xl px-4 pb-4"> <DrawerContent className="mx-1 flex max-h-[75dvh] flex-col items-center gap-2 overflow-hidden rounded-t-2xl px-4 pb-4">
<div <div
className={`mx-4 w-full py-2 text-center capitalize ${selected == "timeline" ? "rounded-lg bg-secondary" : ""}`} className={`mx-4 w-full py-2 text-center smart-capitalize ${selected == "timeline" ? "rounded-lg bg-secondary" : ""}`}
onClick={() => { onClick={() => {
onSelect("timeline"); onSelect("timeline");
setDrawer(false); setDrawer(false);
@ -41,7 +41,7 @@ export default function MobileTimelineDrawer({
Timeline Timeline
</div> </div>
<div <div
className={`mx-4 w-full py-2 text-center capitalize ${selected == "events" ? "rounded-lg bg-secondary" : ""}`} className={`mx-4 w-full py-2 text-center smart-capitalize ${selected == "events" ? "rounded-lg bg-secondary" : ""}`}
onClick={() => { onClick={() => {
onSelect("events"); onSelect("events");
setDrawer(false); setDrawer(false);

View File

@ -572,7 +572,7 @@ export default function ObjectLifecycle({
</div> </div>
</div> </div>
<div className="mx-3 text-lg"> <div className="mx-3 text-lg">
<div className="flex flex-row items-center capitalize text-primary"> <div className="flex flex-row items-center text-primary smart-capitalize">
{getLifecycleItemDescription(item)} {getLifecycleItemDescription(item)}
</div> </div>
<div className="text-sm text-primary-variant"> <div className="text-sm text-primary-variant">
@ -616,7 +616,7 @@ export default function ObjectLifecycle({
)} )}
<div <div
key={index} key={index}
className="cursor-pointer capitalize" className="cursor-pointer smart-capitalize"
onClick={() => setSelectedZone(zone)} onClick={() => setSelectedZone(zone)}
> >
{zone.replaceAll("_", " ")} {zone.replaceAll("_", " ")}
@ -722,7 +722,7 @@ export default function ObjectLifecycle({
/> />
</TooltipTrigger> </TooltipTrigger>
<TooltipPortal> <TooltipPortal>
<TooltipContent className="capitalize"> <TooltipContent className="smart-capitalize">
{getLifecycleItemDescription(item)} {getLifecycleItemDescription(item)}
</TooltipContent> </TooltipContent>
</TooltipPortal> </TooltipPortal>

View File

@ -100,7 +100,7 @@ export function ObjectPath({
/> />
</TooltipTrigger> </TooltipTrigger>
<TooltipPortal> <TooltipPortal>
<TooltipContent side="top" className="capitalize"> <TooltipContent side="top" className="smart-capitalize">
{pos.lifecycle_item {pos.lifecycle_item
? getLifecycleItemDescription(pos.lifecycle_item) ? getLifecycleItemDescription(pos.lifecycle_item)
: "Tracked point"} : "Tracked point"}

View File

@ -223,7 +223,9 @@ export default function ObjectPathPlotter() {
}} }}
/> />
<span className="text-sm"> <span className="text-sm">
<strong className="mr-1 capitalize">{event.label}</strong> <strong className="mr-1 smart-capitalize">
{event.label}
</strong>
{formatUnixTimestampToDateTime(event.start_time, { {formatUnixTimestampToDateTime(event.start_time, {
timezone: config?.ui.timezone, timezone: config?.ui.timezone,
})} })}

View File

@ -233,7 +233,7 @@ export default function ReviewDetailDialog({
<div className="text-sm text-primary/40"> <div className="text-sm text-primary/40">
{t("details.camera")} {t("details.camera")}
</div> </div>
<div className="text-sm capitalize"> <div className="text-sm smart-capitalize">
{review.camera.replaceAll("_", " ")} {review.camera.replaceAll("_", " ")}
</div> </div>
</div> </div>
@ -249,12 +249,12 @@ export default function ReviewDetailDialog({
<div className="text-sm text-primary/40"> <div className="text-sm text-primary/40">
{t("details.objects")} {t("details.objects")}
</div> </div>
<div className="scrollbar-container flex max-h-32 flex-col items-start gap-2 overflow-y-auto text-sm capitalize"> <div className="scrollbar-container flex max-h-32 flex-col items-start gap-2 overflow-y-auto text-sm smart-capitalize">
{events?.map((event) => { {events?.map((event) => {
return ( return (
<div <div
key={event.id} key={event.id}
className="flex flex-row items-center gap-2 capitalize" className="flex flex-row items-center gap-2 smart-capitalize"
> >
{getIconForLabel( {getIconForLabel(
event.label, event.label,
@ -290,12 +290,12 @@ export default function ReviewDetailDialog({
<div className="text-sm text-primary/40"> <div className="text-sm text-primary/40">
{t("details.zones")} {t("details.zones")}
</div> </div>
<div className="flex flex-col items-start gap-2 text-sm capitalize"> <div className="flex flex-col items-start gap-2 text-sm smart-capitalize">
{review.data.zones.map((zone) => { {review.data.zones.map((zone) => {
return ( return (
<div <div
key={zone} key={zone}
className="flex flex-row items-center gap-2 capitalize" className="flex flex-row items-center gap-2 smart-capitalize"
> >
{zone.replaceAll("_", " ")} {zone.replaceAll("_", " ")}
</div> </div>

View File

@ -231,7 +231,7 @@ export default function SearchDetailDialog({
{item == "object_lifecycle" && ( {item == "object_lifecycle" && (
<FaRotate className="size-4" /> <FaRotate className="size-4" />
)} )}
<div className="capitalize">{t(`type.${item}`)}</div> <div className="smart-capitalize">{t(`type.${item}`)}</div>
</ToggleGroupItem> </ToggleGroupItem>
))} ))}
</ToggleGroup> </ToggleGroup>
@ -711,7 +711,7 @@ function ObjectDetailsTab({
<div className="flex w-full flex-col gap-3"> <div className="flex w-full flex-col gap-3">
<div className="flex flex-col gap-1.5"> <div className="flex flex-col gap-1.5">
<div className="text-sm text-primary/40">{t("details.label")}</div> <div className="text-sm text-primary/40">{t("details.label")}</div>
<div className="flex flex-row items-center gap-2 text-sm capitalize"> <div className="flex flex-row items-center gap-2 text-sm smart-capitalize">
{getIconForLabel(search.label, "size-4 text-primary")} {getIconForLabel(search.label, "size-4 text-primary")}
{t(search.label, { {t(search.label, {
ns: "objects", ns: "objects",
@ -831,7 +831,7 @@ function ObjectDetailsTab({
)} )}
<div className="flex flex-col gap-1.5"> <div className="flex flex-col gap-1.5">
<div className="text-sm text-primary/40">{t("details.camera")}</div> <div className="text-sm text-primary/40">{t("details.camera")}</div>
<div className="text-sm capitalize"> <div className="text-sm smart-capitalize">
{search.camera.replaceAll("_", " ")} {search.camera.replaceAll("_", " ")}
</div> </div>
</div> </div>

View File

@ -361,7 +361,7 @@ export default function LivePlayer({
</TooltipTrigger> </TooltipTrigger>
</div> </div>
<TooltipPortal> <TooltipPortal>
<TooltipContent className="capitalize"> <TooltipContent className="smart-capitalize">
{[ {[
...new Set([ ...new Set([
...(objects || []).map(({ label, sub_label }) => ...(objects || []).map(({ label, sub_label }) =>

View File

@ -262,7 +262,7 @@ export default function PreviewThumbnailPlayer({
</div> </div>
</TooltipTrigger> </TooltipTrigger>
</div> </div>
<TooltipContent className="capitalize"> <TooltipContent className="smart-capitalize">
{[ {[
...new Set([ ...new Set([
...(review.data.objects || []), ...(review.data.objects || []),

View File

@ -185,7 +185,7 @@ export function CameraStreamingDialog({
return ( return (
<DialogContent className="sm:max-w-[425px]"> <DialogContent className="sm:max-w-[425px]">
<DialogHeader className="mb-4"> <DialogHeader className="mb-4">
<DialogTitle className="capitalize"> <DialogTitle className="smart-capitalize">
{t("group.camera.setting.title", { {t("group.camera.setting.title", {
cameraName: camera.replaceAll("_", " "), cameraName: camera.replaceAll("_", " "),
})} })}

View File

@ -933,7 +933,7 @@ export function ZoneObjectSelector({
{allLabels.map((item) => ( {allLabels.map((item) => (
<div key={item} className="flex items-center justify-between"> <div key={item} className="flex items-center justify-between">
<Label <Label
className="w-full cursor-pointer capitalize text-primary" className="w-full cursor-pointer text-primary smart-capitalize"
htmlFor={item} htmlFor={item}
> >
{t(item, { ns: "objects" })} {t(item, { ns: "objects" })}

View File

@ -151,7 +151,7 @@ function Exports() {
<DialogContent <DialogContent
className={cn("max-w-[80%]", isMobile && "landscape:max-w-[60%]")} className={cn("max-w-[80%]", isMobile && "landscape:max-w-[60%]")}
> >
<DialogTitle className="capitalize"> <DialogTitle className="smart-capitalize">
{selected?.name?.replaceAll("_", " ")} {selected?.name?.replaceAll("_", " ")}
</DialogTitle> </DialogTitle>
<video <video

View File

@ -395,7 +395,7 @@ function LibrarySelector({
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger asChild> <DropdownMenuTrigger asChild>
<Button className="flex justify-between capitalize"> <Button className="flex justify-between smart-capitalize">
{pageToggle || t("selectFace")} {pageToggle || t("selectFace")}
<span className="ml-2 text-primary-variant"> <span className="ml-2 text-primary-variant">
({(pageToggle && faceData?.[pageToggle]?.length) || 0}) ({(pageToggle && faceData?.[pageToggle]?.length) || 0})
@ -432,7 +432,7 @@ function LibrarySelector({
className="group flex items-center justify-between" className="group flex items-center justify-between"
> >
<div <div
className="flex-grow cursor-pointer capitalize" className="flex-grow cursor-pointer smart-capitalize"
onClick={() => setPageToggle(face)} onClick={() => setPageToggle(face)}
> >
{face} {face}
@ -562,7 +562,7 @@ function TrainingGrid({
</DialogHeader> </DialogHeader>
<div className="flex flex-col gap-1.5"> <div className="flex flex-col gap-1.5">
<div className="text-sm text-primary/40">{t("details.person")}</div> <div className="text-sm text-primary/40">{t("details.person")}</div>
<div className="text-sm capitalize"> <div className="text-sm smart-capitalize">
{selectedEvent?.sub_label ?? "Unknown"} {selectedEvent?.sub_label ?? "Unknown"}
</div> </div>
</div> </div>
@ -571,7 +571,7 @@ function TrainingGrid({
<div className="text-sm text-primary/40"> <div className="text-sm text-primary/40">
{t("details.confidence")} {t("details.confidence")}
</div> </div>
<div className="text-sm capitalize"> <div className="text-sm smart-capitalize">
{Math.round(selectedEvent?.data?.sub_label_score || 0) * 100}% {Math.round(selectedEvent?.data?.sub_label_score || 0) * 100}%
</div> </div>
</div> </div>
@ -694,7 +694,7 @@ function FaceAttemptGroup({
}} }}
> >
<div className="flex flex-row justify-between"> <div className="flex flex-row justify-between">
<div className="select-none capitalize"> <div className="select-none smart-capitalize">
Person Person
{event?.sub_label {event?.sub_label
? `: ${event.sub_label} (${Math.round((event.data.sub_label_score || 0) * 100)}%)` ? `: ${event.sub_label} (${Math.round((event.data.sub_label_score || 0) * 100)}%)`
@ -873,7 +873,7 @@ function FaceAttempt({
<div className="select-none p-2"> <div className="select-none p-2">
<div className="flex w-full flex-row items-center justify-between gap-2"> <div className="flex w-full flex-row items-center justify-between gap-2">
<div className="flex flex-col items-start text-xs text-primary-variant"> <div className="flex flex-col items-start text-xs text-primary-variant">
<div className="capitalize">{data.name}</div> <div className="smart-capitalize">{data.name}</div>
<div <div
className={cn( className={cn(
"", "",
@ -957,7 +957,7 @@ function FaceImage({ name, image, onDelete }: FaceImageProps) {
<div className="rounded-b-lg bg-card p-2"> <div className="rounded-b-lg bg-card p-2">
<div className="flex w-full flex-row items-center justify-between gap-2"> <div className="flex w-full flex-row items-center justify-between gap-2">
<div className="flex flex-col items-start text-xs text-primary-variant"> <div className="flex flex-col items-start text-xs text-primary-variant">
<div className="capitalize">{name}</div> <div className="smart-capitalize">{name}</div>
</div> </div>
<div className="flex flex-row items-start justify-end gap-5 md:gap-4"> <div className="flex flex-row items-start justify-end gap-5 md:gap-4">
<Tooltip> <Tooltip>

View File

@ -493,7 +493,7 @@ function Logs() {
data-nav-item={item} data-nav-item={item}
aria-label={`Select ${item}`} aria-label={`Select ${item}`}
> >
<div className="capitalize">{item}</div> <div className="smart-capitalize">{item}</div>
</ToggleGroupItem> </ToggleGroupItem>
))} ))}
</ToggleGroup> </ToggleGroup>
@ -536,7 +536,7 @@ function Logs() {
<div className="grid grid-cols-5 *:px-0 *:py-3 *:text-sm *:text-primary/40 md:grid-cols-12"> <div className="grid grid-cols-5 *:px-0 *:py-3 *:text-sm *:text-primary/40 md:grid-cols-12">
<div className="col-span-3 lg:col-span-2"> <div className="col-span-3 lg:col-span-2">
<div className="flex w-full flex-row items-center"> <div className="flex w-full flex-row items-center">
<div className="ml-1 min-w-16 capitalize lg:min-w-20"> <div className="ml-1 min-w-16 smart-capitalize lg:min-w-20">
{t("logs.type.label")} {t("logs.type.label")}
</div> </div>
<div className="mr-3">{t("logs.type.timestamp")}</div> <div className="mr-3">{t("logs.type.timestamp")}</div>

View File

@ -219,7 +219,7 @@ export default function Settings() {
item: t("menu." + item), item: t("menu." + item),
})} })}
> >
<div className="capitalize">{t("menu." + item)}</div> <div className="smart-capitalize">{t("menu." + item)}</div>
</ToggleGroupItem> </ToggleGroupItem>
))} ))}
</ToggleGroup> </ToggleGroup>
@ -336,7 +336,7 @@ function CameraSelectButton({
const trigger = ( const trigger = (
<Button <Button
className="flex items-center gap-2 bg-selected capitalize hover:bg-selected" className="flex items-center gap-2 bg-selected smart-capitalize hover:bg-selected"
aria-label="Select a camera" aria-label="Select a camera"
size="sm" size="sm"
> >

View File

@ -93,7 +93,7 @@ function System() {
{item == "storage" && <LuHardDrive className="size-4" />} {item == "storage" && <LuHardDrive className="size-4" />}
{item == "cameras" && <FaVideo className="size-4" />} {item == "cameras" && <FaVideo className="size-4" />}
{isDesktop && ( {isDesktop && (
<div className="capitalize">{t(item + ".title")}</div> <div className="smart-capitalize">{t(item + ".title")}</div>
)} )}
</ToggleGroupItem> </ToggleGroupItem>
))} ))}

View File

@ -80,7 +80,7 @@ i18n
.join(" "); .join(" ");
} }
// For single keys, just capitalize and format // For single keys, just smart-capitalize and format
return key return key
.split("_") .split("_")
.map( .map(

View File

@ -151,7 +151,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 capitalize"> <div className="flex flex-row items-center text-lg smart-capitalize">
{t(objectType, { ns: "objects" })} {t(objectType, { ns: "objects" })}
{searchResults && ( {searchResults && (
<span className="ml-3 text-sm text-secondary-foreground"> <span className="ml-3 text-sm text-secondary-foreground">
@ -190,7 +190,7 @@ function ThumbnailRow({
/> />
</TooltipTrigger> </TooltipTrigger>
<TooltipPortal> <TooltipPortal>
<TooltipContent className="capitalize"> <TooltipContent className="smart-capitalize">
<ExploreMoreLink objectType={objectType} /> <ExploreMoreLink objectType={objectType} />
</TooltipContent> </TooltipContent>
</TooltipPortal> </TooltipPortal>

View File

@ -597,7 +597,7 @@ export default function SearchView({
<Tooltip> <Tooltip>
<TooltipTrigger> <TooltipTrigger>
<Chip <Chip
className={`flex select-none items-center justify-between space-x-1 bg-gray-500 bg-gradient-to-br from-gray-400 to-gray-500 text-xs capitalize text-white`} className={`flex select-none items-center justify-between space-x-1 bg-gray-500 bg-gradient-to-br from-gray-400 to-gray-500 text-xs text-white smart-capitalize`}
> >
{value.search_source == "thumbnail" ? ( {value.search_source == "thumbnail" ? (
<LuImage className="size-3" /> <LuImage className="size-3" />

View File

@ -431,7 +431,7 @@ export default function CameraSettingsView({
}} }}
/> />
</FormControl> </FormControl>
<FormLabel className="font-normal capitalize"> <FormLabel className="font-normal smart-capitalize">
{zone.name.replaceAll("_", " ")} {zone.name.replaceAll("_", " ")}
</FormLabel> </FormLabel>
</FormItem> </FormItem>
@ -536,7 +536,7 @@ export default function CameraSettingsView({
}} }}
/> />
</FormControl> </FormControl>
<FormLabel className="font-normal capitalize"> <FormLabel className="font-normal smart-capitalize">
{zone.name.replaceAll("_", " ")} {zone.name.replaceAll("_", " ")}
</FormLabel> </FormLabel>
</FormItem> </FormItem>

View File

@ -680,7 +680,7 @@ export function CameraNotificationSwitch({
)} )}
<div className="flex flex-col"> <div className="flex flex-col">
<Label <Label
className="text-md cursor-pointer capitalize text-primary" className="text-md cursor-pointer text-primary smart-capitalize"
htmlFor="camera" htmlFor="camera"
> >
{camera.replaceAll("_", " ")} {camera.replaceAll("_", " ")}

View File

@ -197,7 +197,7 @@ export default function ObjectSettingsView({
<div className="mb-2 flex flex-col"> <div className="mb-2 flex flex-col">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<Label <Label
className="mb-0 cursor-pointer capitalize text-primary" className="mb-0 cursor-pointer text-primary smart-capitalize"
htmlFor={param} htmlFor={param}
> >
{title} {title}
@ -239,7 +239,7 @@ export default function ObjectSettingsView({
<div className="mb-2 flex flex-col"> <div className="mb-2 flex flex-col">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<Label <Label
className="mb-0 cursor-pointer capitalize text-primary" className="mb-0 cursor-pointer text-primary smart-capitalize"
htmlFor="debugdraw" htmlFor="debugdraw"
> >
{t("debug.objectShapeFilterDrawing.title")} {t("debug.objectShapeFilterDrawing.title")}

View File

@ -259,7 +259,7 @@ export default function CameraMetrics({
)} )}
<div className="flex w-full flex-col gap-3"> <div className="flex w-full flex-col gap-3">
<div className="flex flex-row items-center justify-between"> <div className="flex flex-row items-center justify-between">
<div className="text-sm font-medium capitalize text-muted-foreground"> <div className="text-sm font-medium text-muted-foreground smart-capitalize">
{camera.name.replaceAll("_", " ")} {camera.name.replaceAll("_", " ")}
</div> </div>
<Tooltip> <Tooltip>

View File

@ -105,7 +105,7 @@ export default function EnrichmentMetrics({
<> <>
{embeddingInferenceTimeSeries.map((series) => ( {embeddingInferenceTimeSeries.map((series) => (
<div className="rounded-lg bg-background_alt p-2.5 md:rounded-2xl"> <div className="rounded-lg bg-background_alt p-2.5 md:rounded-2xl">
<div className="mb-5 capitalize">{series.name}</div> <div className="mb-5 smart-capitalize">{series.name}</div>
{series.name.endsWith("Speed") ? ( {series.name.endsWith("Speed") ? (
<ThresholdBarGraph <ThresholdBarGraph
key={series.name} key={series.name}

View File

@ -1,4 +1,7 @@
/** @type {import('tailwindcss').Config} */ /** @type {import('tailwindcss').Config} */
const plugin = require("tailwindcss/plugin");
module.exports = { module.exports = {
darkMode: ["class"], darkMode: ["class"],
content: [ content: [
@ -166,5 +169,16 @@ module.exports = {
require("tailwindcss-animate"), require("tailwindcss-animate"),
// eslint-disable-next-line @typescript-eslint/no-var-requires // eslint-disable-next-line @typescript-eslint/no-var-requires
require("tailwind-scrollbar")({ nocompatible: true }), require("tailwind-scrollbar")({ nocompatible: true }),
plugin(function ({ addUtilities }) {
addUtilities({
".smart-capitalize": {
':root[lang="ru"] &, :root[lang="ar"] &, :root[lang="he"] &, :root[lang="zh"] &, :root[lang="ja"] &, :root[lang="ko"] &, :root[lang="hi"] &, :root[lang="th"] &':
{
textTransform: "none",
},
textTransform: "capitalize",
},
});
}),
], ],
}; };