Skip to content

Commit f3543cf

Browse files
authored
I18N Miscellaneous Fixes (#21573)
* fix: fix classification none tag i18n wrong * fix: fix set password dialog jwt time i18n wrong * fix: fix wizard other camera i18n * fix: fix explore tracking detail audio i18n * feat: add system processes info i18n * fix: fix live page label i18n
1 parent 74d14cb commit f3543cf

File tree

10 files changed

+49
-26
lines changed

10 files changed

+49
-26
lines changed

web/public/locales/en/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@
101101
"show": "Show {{item}}",
102102
"ID": "ID",
103103
"none": "None",
104-
"all": "All"
104+
"all": "All",
105+
"other": "Other"
105106
},
106107
"list": {
107108
"two": "{{0}} and {{1}}",

web/public/locales/en/views/system.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@
8686
"otherProcesses": {
8787
"title": "Other Processes",
8888
"processCpuUsage": "Process CPU Usage",
89-
"processMemoryUsage": "Process Memory Usage"
89+
"processMemoryUsage": "Process Memory Usage",
90+
"series": {
91+
"go2rtc": "go2rtc",
92+
"recording": "recording",
93+
"review_segment": "review segment",
94+
"embeddings": "embeddings",
95+
"audio_detector": "audio detector"
96+
}
9097
}
9198
},
9299
"storage": {

web/src/components/card/ClassificationCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export const ClassificationCard = forwardRef<
166166
<div className="break-all smart-capitalize">
167167
{data.name == "unknown"
168168
? t("details.unknown")
169-
: data.name == "none"
169+
: data.name.toLowerCase() == "none"
170170
? t("details.none")
171171
: data.name}
172172
</div>

web/src/components/overlay/SetPasswordDialog.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { useTranslation } from "react-i18next";
2222
import { useDocDomain } from "@/hooks/use-doc-domain";
2323
import useSWR from "swr";
2424
import { formatSecondsToDuration } from "@/utils/dateUtil";
25+
import { useDateLocale } from "@/hooks/use-date-locale";
2526
import ActivityIndicator from "../indicators/activity-indicator";
2627
import { zodResolver } from "@hookform/resolvers/zod";
2728
import { useForm } from "react-hook-form";
@@ -48,12 +49,13 @@ export default function SetPasswordDialog({
4849
const { t } = useTranslation(["views/settings", "common"]);
4950
const { getLocaleDocUrl } = useDocDomain();
5051
const isAdmin = useIsAdmin();
52+
const dateLocale = useDateLocale();
5153

5254
const { data: config } = useSWR("config");
5355
const refreshSeconds: number | undefined =
5456
config?.auth?.refresh_time ?? undefined;
5557
const refreshTimeLabel = refreshSeconds
56-
? formatSecondsToDuration(refreshSeconds)
58+
? formatSecondsToDuration(refreshSeconds, dateLocale)
5759
: t("time.30minutes", { ns: "common" });
5860

5961
// visibility toggles for password fields

web/src/components/overlay/detail/TrackingDetails.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ export function TrackingDetails({
266266

267267
const label = event.sub_label
268268
? event.sub_label
269-
: getTranslatedLabel(event.label);
269+
: getTranslatedLabel(event.label, event.data.type);
270270

271271
const getZoneColor = useCallback(
272272
(zoneName: string) => {
@@ -998,7 +998,7 @@ function LifecycleIconRow({
998998
<div className="ml-3 flex-shrink-0 px-1 text-right text-xs text-primary-variant">
999999
<div className="flex flex-row items-center gap-3">
10001000
<div className="whitespace-nowrap">{formattedEventTimestamp}</div>
1001-
{((isAdmin && config?.plus?.enabled) || item.data.box) && (
1001+
{isAdmin && config?.plus?.enabled && item.data.box && (
10021002
<DropdownMenu open={isOpen} onOpenChange={setIsOpen}>
10031003
<DropdownMenuTrigger>
10041004
<div className="rounded p-1 pr-2" role="button">

web/src/components/player/LivePlayer.tsx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
} from "@/types/live";
1717
import { getIconForLabel } from "@/utils/iconUtil";
1818
import Chip from "../indicators/Chip";
19-
import { capitalizeFirstLetter } from "@/utils/stringUtil";
2019
import { cn } from "@/lib/utils";
2120
import { TbExclamationCircle } from "react-icons/tb";
2221
import { TooltipPortal } from "@radix-ui/react-tooltip";
@@ -26,6 +25,8 @@ import { LuVideoOff } from "react-icons/lu";
2625
import { Trans, useTranslation } from "react-i18next";
2726
import { useCameraFriendlyName } from "@/hooks/use-camera-friendly-name";
2827
import { ImageShadowOverlay } from "../overlay/ImageShadowOverlay";
28+
import { getTranslatedLabel } from "@/utils/i18n";
29+
import { formatList } from "@/utils/stringUtil";
2930

3031
type LivePlayerProps = {
3132
cameraRef?: (ref: HTMLDivElement | null) => void;
@@ -367,20 +368,22 @@ export default function LivePlayer({
367368
</div>
368369
<TooltipPortal>
369370
<TooltipContent className="smart-capitalize">
370-
{[
371-
...new Set([
372-
...(objects || []).map(({ label, sub_label }) =>
373-
label.endsWith("verified")
374-
? sub_label
375-
: label.replaceAll("_", " "),
376-
),
377-
]),
378-
]
379-
.filter((label) => label?.includes("-verified") == false)
380-
.map((label) => capitalizeFirstLetter(label))
381-
.sort()
382-
.join(", ")
383-
.replaceAll("-verified", "")}
371+
{formatList(
372+
[
373+
...new Set([
374+
...(objects || []).map(({ label, sub_label }) =>
375+
label.endsWith("verified")
376+
? sub_label
377+
: label.replaceAll("_", " "),
378+
),
379+
]),
380+
]
381+
.filter((label) => label?.includes("-verified") == false)
382+
.map((label) =>
383+
getTranslatedLabel(label.replace("-verified", "")),
384+
)
385+
.sort(),
386+
)}
384387
</TooltipContent>
385388
</TooltipPortal>
386389
</Tooltip>

web/src/components/settings/wizard/Step1NameCamera.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,9 @@ export default function Step1NameCamera({
417417
<SelectContent>
418418
{CAMERA_BRANDS.map((brand) => (
419419
<SelectItem key={brand.value} value={brand.value}>
420-
{brand.label}
420+
{brand.label.toLowerCase() === "other"
421+
? t("label.other", { ns: "common" })
422+
: brand.label}
421423
</SelectItem>
422424
))}
423425
</SelectContent>

web/src/utils/dateUtil.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { fromUnixTime, intervalToDuration, formatDuration } from "date-fns";
2-
import { Locale } from "date-fns/locale";
2+
import { enUS, Locale } from "date-fns/locale";
33
import { formatInTimeZone } from "date-fns-tz";
44
import i18n from "@/utils/i18n";
55
export const longToDate = (long: number): Date => new Date(long * 1000);
@@ -293,9 +293,13 @@ export const getDurationFromTimestamps = (
293293
/**
294294
*
295295
* @param seconds - number of seconds to convert into hours, minutes and seconds
296+
* @param locale - the date-fns locale to use for formatting
296297
* @returns string - formatted duration in hours, minutes and seconds
297298
*/
298-
export const formatSecondsToDuration = (seconds: number): string => {
299+
export const formatSecondsToDuration = (
300+
seconds: number,
301+
locale?: Locale,
302+
): string => {
299303
if (isNaN(seconds) || seconds < 0) {
300304
return "Invalid duration";
301305
}
@@ -304,6 +308,7 @@ export const formatSecondsToDuration = (seconds: number): string => {
304308
return formatDuration(duration, {
305309
format: ["hours", "minutes", "seconds"],
306310
delimiter: ", ",
311+
locale: locale ?? enUS,
307312
});
308313
};
309314

web/src/utils/lifecycleUtil.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ export function getLifecycleItemDescription(
1212

1313
const label = lifecycleItem.data.sub_label
1414
? capitalizeFirstLetter(rawLabel)
15-
: getTranslatedLabel(rawLabel);
15+
: getTranslatedLabel(
16+
rawLabel,
17+
lifecycleItem.class_type === "heard" ? "audio" : "object",
18+
);
1619

1720
switch (lifecycleItem.class_type) {
1821
case "visible":

web/src/views/system/GeneralMetrics.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ export default function GeneralMetrics({
855855
<ThresholdBarGraph
856856
key={series.name}
857857
graphId={`${series.name}-cpu`}
858-
name={series.name.replaceAll("_", " ")}
858+
name={t(`general.otherProcesses.series.${series.name}`)}
859859
unit="%"
860860
threshold={DetectorCpuThreshold}
861861
updateTimes={updateTimes}

0 commit comments

Comments
 (0)