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",
"description": "settings for audio-based event detection; camera-level settings can override these.",
"groups": {
"detection": "Detection",
"sensitivity": "Sensitivity"
},
"enabled": {
"label": "Enable audio events",
"description": "Enable or disable audio event detection globally. Can be overridden per camera."

View File

@ -1,10 +1,6 @@
{
"label": "Object Detection",
"description": "Settings for the detection/detect role used to run object detection and initialize trackers.",
"groups": {
"resolution": "Resolution",
"tracking": "Tracking"
},
"enabled": {
"label": "Detection Enabled",
"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",
"description": "Default motion detection settings applied to cameras unless overridden per-camera.",
"groups": {
"sensitivity": "Sensitivity",
"algorithm": "Algorithm"
},
"enabled": {
"label": "Enable motion detection",
"description": "Enable or disable motion detection globally; per-camera settings can override this."

View File

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

View File

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

View File

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

View File

@ -1,9 +1,6 @@
{
"label": "Timestamp style",
"description": "Styling options for in-feed timestamps applied to recordings and snapshots.",
"groups": {
"appearance": "Appearance"
},
"position": {
"label": "Timestamp position",
"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 { 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 =
(uiSchema?.["ui:groups"] as Record<string, string[]> | undefined) || {};
@ -120,9 +131,14 @@ export function ObjectFieldTemplate(props: ObjectFieldTemplateProps) {
ordered.forEach((item) => grouped.add(item.name));
const label = t(`groups.${groupKey}`, {
defaultValue: toTitle(groupKey),
});
const label = domain
? t(`${domain}.${groupKey}`, {
ns: "config/groups",
defaultValue: toTitle(groupKey),
})
: t(`groups.${groupKey}`, {
defaultValue: toTitle(groupKey),
});
return {
key: groupKey,

View File

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