add config groups as a separate i18n namespace

This commit is contained in:
Josh Hawkins 2026-01-29 08:40:29 -06:00
parent 3fc07e507a
commit aad24497bf
10 changed files with 49 additions and 30 deletions

View File

@ -1,10 +1,6 @@
{ {
"label": "Audio events", "label": "Audio events",
"description": "settings for audio-based event detection; camera-level settings can override these.", "description": "settings for audio-based event detection; camera-level settings can override these.",
"groups": {
"detection": "Detection",
"sensitivity": "Sensitivity"
},
"enabled": { "enabled": {
"label": "Enable audio events", "label": "Enable audio events",
"description": "Enable or disable audio event detection globally. Can be overridden per camera." "description": "Enable or disable audio event detection globally. Can be overridden per camera."

View File

@ -1,10 +1,6 @@
{ {
"label": "Object Detection", "label": "Object Detection",
"description": "Settings for the detection/detect role used to run object detection and initialize trackers.", "description": "Settings for the detection/detect role used to run object detection and initialize trackers.",
"groups": {
"resolution": "Resolution",
"tracking": "Tracking"
},
"enabled": { "enabled": {
"label": "Detection Enabled", "label": "Detection Enabled",
"description": "Enable or disable object detection for this camera. Detection must be enabled for object tracking to run." "description": "Enable or disable object detection for this camera. Detection must be enabled for object tracking to run."

View File

@ -0,0 +1,28 @@
{
"audio": {
"detection": "Detection",
"sensitivity": "Sensitivity"
},
"timestamp_style": {
"appearance": "Appearance"
},
"motion": {
"sensitivity": "Sensitivity",
"algorithm": "Algorithm"
},
"snapshots": {
"display": "Display"
},
"detect": {
"resolution": "Resolution",
"tracking": "Tracking"
},
"objects": {
"tracking": "Tracking",
"filtering": "Filtering"
},
"record": {
"retention": "Retention",
"events": "Events"
}
}

View File

@ -1,10 +1,6 @@
{ {
"label": "Motion detection", "label": "Motion detection",
"description": "Default motion detection settings applied to cameras unless overridden per-camera.", "description": "Default motion detection settings applied to cameras unless overridden per-camera.",
"groups": {
"sensitivity": "Sensitivity",
"algorithm": "Algorithm"
},
"enabled": { "enabled": {
"label": "Enable motion detection", "label": "Enable motion detection",
"description": "Enable or disable motion detection globally; per-camera settings can override this." "description": "Enable or disable motion detection globally; per-camera settings can override this."

View File

@ -1,10 +1,6 @@
{ {
"label": "Objects", "label": "Objects",
"description": "Object tracking defaults including which labels to track and per-object filters.", "description": "Object tracking defaults including which labels to track and per-object filters.",
"groups": {
"tracking": "Tracking",
"filtering": "Filtering"
},
"track": { "track": {
"label": "Objects to track", "label": "Objects to track",
"description": "List of object labels to track globally; camera configs can override this." "description": "List of object labels to track globally; camera configs can override this."

View File

@ -1,10 +1,6 @@
{ {
"label": "Recording", "label": "Recording",
"description": "Recording and retention settings applied to cameras unless overridden per-camera.", "description": "Recording and retention settings applied to cameras unless overridden per-camera.",
"groups": {
"retention": "Retention",
"events": "Events"
},
"enabled": { "enabled": {
"label": "Enable record on all cameras", "label": "Enable record on all cameras",
"description": "Enable or disable recording globally; individual cameras can override this." "description": "Enable or disable recording globally; individual cameras can override this."

View File

@ -1,9 +1,6 @@
{ {
"label": "Snapshots", "label": "Snapshots",
"description": "Settings for saved JPEG snapshots of tracked objects; can be overridden per-camera.", "description": "Settings for saved JPEG snapshots of tracked objects; can be overridden per-camera.",
"groups": {
"display": "Display"
},
"enabled": { "enabled": {
"label": "Snapshots enabled", "label": "Snapshots enabled",
"description": "Enable or disable saving snapshots globally." "description": "Enable or disable saving snapshots globally."

View File

@ -1,9 +1,6 @@
{ {
"label": "Timestamp style", "label": "Timestamp style",
"description": "Styling options for in-feed timestamps applied to recordings and snapshots.", "description": "Styling options for in-feed timestamps applied to recordings and snapshots.",
"groups": {
"appearance": "Appearance"
},
"position": { "position": {
"label": "Timestamp position", "label": "Timestamp position",
"description": "Position of the timestamp on the image (tl/tr/bl/br)." "description": "Position of the timestamp on the image (tl/tr/bl/br)."

View File

@ -30,7 +30,18 @@ export function ObjectFieldTemplate(props: ObjectFieldTemplateProps) {
const [isOpen, setIsOpen] = useState(true); const [isOpen, setIsOpen] = useState(true);
const { t } = useTranslation([formContext?.i18nNamespace || "common"]); const { t } = useTranslation([
formContext?.i18nNamespace || "common",
"config/groups",
]);
// Extract domain from i18nNamespace (e.g., "config/audio" -> "audio")
const getDomainFromNamespace = (ns?: string): string => {
if (!ns || !ns.startsWith("config/")) return "";
return ns.replace("config/", "");
};
const domain = getDomainFromNamespace(formContext?.i18nNamespace);
const groupDefinitions = const groupDefinitions =
(uiSchema?.["ui:groups"] as Record<string, string[]> | undefined) || {}; (uiSchema?.["ui:groups"] as Record<string, string[]> | undefined) || {};
@ -120,7 +131,12 @@ export function ObjectFieldTemplate(props: ObjectFieldTemplateProps) {
ordered.forEach((item) => grouped.add(item.name)); ordered.forEach((item) => grouped.add(item.name));
const label = t(`groups.${groupKey}`, { const label = domain
? t(`${domain}.${groupKey}`, {
ns: "config/groups",
defaultValue: toTitle(groupKey),
})
: t(`groups.${groupKey}`, {
defaultValue: toTitle(groupKey), defaultValue: toTitle(groupKey),
}); });

View File

@ -73,6 +73,7 @@ i18n
"config/face_recognition", "config/face_recognition",
"config/lpr", "config/lpr",
"config/validation", "config/validation",
"config/groups",
], ],
defaultNS: "common", defaultNS: "common",