use label i18n

This commit is contained in:
Josh Hawkins 2026-05-04 10:44:02 -05:00
parent 3499d24f32
commit b870928510

View File

@ -111,7 +111,11 @@ function groupDeltasBySource(deltas: FieldDelta[]): SourceGroup[] {
} }
function CameraEntry({ sectionPath, entry, cameraPage }: CameraEntryProps) { function CameraEntry({ sectionPath, entry, cameraPage }: CameraEntryProps) {
const { t, i18n } = useTranslation(["config/global", "views/settings"]); const { t, i18n } = useTranslation([
"config/global",
"views/settings",
"objects",
]);
const friendlyName = useCameraFriendlyName(entry.camera); const friendlyName = useCameraFriendlyName(entry.camera);
const { data: profilesData } = useSWR<ProfilesApiResponse>("profiles"); const { data: profilesData } = useSWR<ProfilesApiResponse>("profiles");
@ -149,8 +153,14 @@ function CameraEntry({ sectionPath, entry, cameraPage }: CameraEntryProps) {
const reducedKey = `${sectionPath}.${reduced}.label`; const reducedKey = `${sectionPath}.${reduced}.label`;
if (i18n.exists(reducedKey, { ns: "config/global" })) { if (i18n.exists(reducedKey, { ns: "config/global" })) {
const resolvedLabel = t(reducedKey, { ns: "config/global" }); const resolvedLabel = t(reducedKey, { ns: "config/global" });
const entry = humanizeKey(segments[i]); const dropped = segments[i];
return `${entry} · ${resolvedLabel}`; // Object class names ("person", "car", "fox") have translations in
// the `objects` namespace; fall back to humanizing the raw key for
// anything that isn't a known label.
const droppedLabel = i18n.exists(dropped, { ns: "objects" })
? t(dropped, { ns: "objects" })
: humanizeKey(dropped);
return `${droppedLabel} · ${resolvedLabel}`;
} }
} }