Refactor and clean up i18n (#17198)

* clean up i18n

* fix key

* fix key
This commit is contained in:
Josh Hawkins
2025-03-17 06:26:01 -06:00
committed by GitHub
parent 6e3ae0afc2
commit 03da70cb81
74 changed files with 1243 additions and 799 deletions
@@ -50,7 +50,7 @@ export function CameraStreamingDialog({
setIsDialogOpen,
onSave,
}: CameraStreamingDialogProps) {
const { t } = useTranslation(["components/camera"]);
const { t } = useTranslation(["components/camera", "components/dialog"]);
const { data: config } = useSWR<FrigateConfig>("config");
const [isLoading, setIsLoading] = useState(false);
@@ -198,7 +198,9 @@ export function CameraStreamingDialog({
</div>
</PopoverTrigger>
<PopoverContent className="w-80 text-xs">
{t("streaming.restreaming.desc", { ns: "components/dialog" })}
{t("streaming.restreaming.desc.title", {
ns: "components/dialog",
})}
<div className="mt-2 flex items-center text-primary">
<Link
to="https://docs.frigate.video/configuration/live"
@@ -206,7 +208,7 @@ export function CameraStreamingDialog({
rel="noopener noreferrer"
className="inline"
>
{t("streaming.restreaming.readTheDocumentation", {
{t("streaming.restreaming.desc.readTheDocumentation", {
ns: "components/dialog",
})}
<LuExternalLink className="ml-2 inline-flex size-3" />
@@ -257,7 +259,7 @@ export function CameraStreamingDialog({
</div>
</PopoverTrigger>
<PopoverContent className="w-80 text-xs">
{t("group.camera.setting.audio.desc")}
{t("group.camera.setting.audio.tips.title")}
<div className="mt-2 flex items-center text-primary">
<Link
to="https://docs.frigate.video/configuration/live"
@@ -265,7 +267,7 @@ export function CameraStreamingDialog({
rel="noopener noreferrer"
className="inline"
>
{t("group.camera.setting.audio.desc.document")}
{t("group.camera.setting.audio.tips.document")}
<LuExternalLink className="ml-2 inline-flex size-3" />
</Link>
</div>
@@ -322,7 +324,7 @@ export function CameraStreamingDialog({
<>
<p className="text-sm text-muted-foreground">
{t(
"group.camera.setting.streamMethod.method.continuousStreaming.desc",
"group.camera.setting.streamMethod.method.continuousStreaming.desc.title",
)}
</p>
<div className="flex items-center gap-2">
@@ -107,7 +107,7 @@ export default function MotionMaskEditPane({
polygon: z.object({ name: z.string(), isFinished: z.boolean() }),
})
.refine(() => polygon?.isFinished === true, {
message: t("masksAndZones.polygonDrawing.error.mustBeFinished"),
message: t("masksAndZones.form.polygonDrawing.error.mustBeFinished"),
path: ["polygon.isFinished"],
});
@@ -166,7 +166,7 @@ export default function MotionMaskEditPane({
if (res.status === 200) {
toast.success(
polygon.name
? t("masksAndZones.motionMasks.toast.success", {
? t("masksAndZones.motionMasks.toast.success.title", {
polygonName: polygon.name,
})
: t("masksAndZones.motionMasks.toast.success.noName"),
@@ -177,7 +177,7 @@ export default function MotionMaskEditPane({
updateConfig();
} else {
toast.error(
t("toast.save.error", {
t("toast.save.error.title", {
errorMessage: res.statusText,
ns: "common",
}),
@@ -192,9 +192,12 @@ export default function MotionMaskEditPane({
error.response?.data?.message ||
error.response?.data?.detail ||
"Unknown error";
toast.error(t("toast.save.error", { errorMessage, ns: "common" }), {
position: "top-center",
});
toast.error(
t("toast.save.error.title", { errorMessage, ns: "common" }),
{
position: "top-center",
},
);
})
.finally(() => {
setIsLoading(false);
@@ -283,7 +286,7 @@ export default function MotionMaskEditPane({
{polygonArea && polygonArea >= 0.35 && (
<>
<div className="mb-3 text-sm text-danger">
{t("masksAndZones.motionMasks.polygonAreaTooLarge", {
{t("masksAndZones.motionMasks.polygonAreaTooLarge.title", {
polygonArea: Math.round(polygonArea * 100),
})}
</div>
@@ -109,7 +109,7 @@ export default function ObjectMaskEditPane({
polygon: z.object({ isFinished: z.boolean(), name: z.string() }),
})
.refine(() => polygon?.isFinished === true, {
message: t("masksAndZones.polygonDrawing.error.mustBeFinished"),
message: t("masksAndZones.form.polygonDrawing.error.mustBeFinished"),
path: ["polygon.isFinished"],
});
@@ -198,7 +198,7 @@ export default function ObjectMaskEditPane({
if (res.status === 200) {
toast.success(
polygon.name
? t("masksAndZones.objectMasks.toast.success", {
? t("masksAndZones.objectMasks.toast.success.title", {
polygonName: polygon.name,
})
: t("masksAndZones.objectMasks.toast.success.noName"),
@@ -209,7 +209,7 @@ export default function ObjectMaskEditPane({
updateConfig();
} else {
toast.error(
t("toast.save.error", {
t("toast.save.error.title", {
errorMessage: res.statusText,
ns: "common",
}),
@@ -225,7 +225,7 @@ export default function ObjectMaskEditPane({
error.response?.data?.detail ||
"Unknown error";
toast.error(
t("toast.save.error", {
t("toast.save.error.title", {
errorMessage,
ns: "common",
}),
@@ -327,7 +327,7 @@ export default function ObjectMaskEditPane({
render={({ field }) => (
<FormItem>
<FormLabel>
{t("masksAndZones.objectMasks.objects")}
{t("masksAndZones.objectMasks.objects.title")}
</FormLabel>
<Select
onValueChange={field.onChange}
+8 -5
View File
@@ -188,9 +188,9 @@ export default function PolygonItem({
updateConfig();
} else {
toast.error(
t("toast.save.error", {
errorMessage: res.statusText,
t("toast.save.error.title", {
ns: "common",
errorMessage: res.statusText,
}),
{
position: "top-center",
@@ -203,9 +203,12 @@ export default function PolygonItem({
error.response?.data?.message ||
error.response?.data?.detail ||
"Unknown error";
toast.error(t("toast.save.error", { errorMessage, ns: "common" }), {
position: "top-center",
});
toast.error(
t("toast.save.error.title", { errorMessage, ns: "common" }),
{
position: "top-center",
},
);
})
.finally(() => {
setIsLoading(false);
@@ -59,7 +59,9 @@ export default function ExploreSettings({
<div className={cn(className, "my-3 space-y-5 py-3 md:mt-0 md:py-0")}>
<div className="space-y-4">
<div className="space-y-0.5">
<div className="text-md">{t("explore.settings.defaultView")}</div>
<div className="text-md">
{t("explore.settings.defaultView.title")}
</div>
<div className="space-y-1 text-xs text-muted-foreground">
{t("explore.settings.defaultView.desc")}
</div>
@@ -95,7 +97,9 @@ export default function ExploreSettings({
<DropdownMenuSeparator />
<div className="flex w-full flex-col space-y-4">
<div className="space-y-0.5">
<div className="text-md">{t("explore.settings.gridColumns")}</div>
<div className="text-md">
{t("explore.settings.gridColumns.title")}
</div>
<div className="space-y-1 text-xs text-muted-foreground">
{t("explore.settings.gridColumns.desc")}
</div>
+21 -18
View File
@@ -161,7 +161,7 @@ export default function ZoneEditPane({
.optional()
.or(z.literal("")),
isFinished: z.boolean().refine(() => polygon?.isFinished === true, {
message: t("masksAndZones.polygonDrawing.error.mustBeFinished"),
message: t("masksAndZones.form.polygonDrawing.error.mustBeFinished"),
}),
objects: z.array(z.string()).optional(),
review_alerts: z.boolean().default(false).optional(),
@@ -170,28 +170,28 @@ export default function ZoneEditPane({
lineA: z.coerce
.number()
.min(0.1, {
message: t("masksAndZones.form.distance.error"),
message: t("masksAndZones.form.distance.error.text"),
})
.optional()
.or(z.literal("")),
lineB: z.coerce
.number()
.min(0.1, {
message: t("masksAndZones.form.distance.error"),
message: t("masksAndZones.form.distance.error.text"),
})
.optional()
.or(z.literal("")),
lineC: z.coerce
.number()
.min(0.1, {
message: t("masksAndZones.form.distance.error"),
message: t("masksAndZones.form.distance.error.text"),
})
.optional()
.or(z.literal("")),
lineD: z.coerce
.number()
.min(0.1, {
message: t("masksAndZones.form.distance.error"),
message: t("masksAndZones.form.distance.error.text"),
})
.optional()
.or(z.literal("")),
@@ -422,7 +422,7 @@ export default function ZoneEditPane({
updateConfig();
} else {
toast.error(
t("toast.save.error", {
t("toast.save.error.title", {
errorMessage: res.statusText,
ns: "common",
}),
@@ -438,7 +438,7 @@ export default function ZoneEditPane({
error.response?.data?.detail ||
"Unknown error";
toast.error(
t("toast.save.error", {
t("toast.save.error.title", {
errorMessage,
ns: "common",
}),
@@ -496,7 +496,7 @@ export default function ZoneEditPane({
: t("masksAndZones.zones.add")}
</Heading>
<div className="my-2 text-sm text-muted-foreground">
<p>{t("masksAndZones.zones.desc")}</p>
<p>{t("masksAndZones.zones.desc.title")}</p>
</div>
<Separator className="my-3 bg-secondary" />
{polygons && activePolygonIndex !== undefined && (
@@ -532,7 +532,7 @@ export default function ZoneEditPane({
name="name"
render={({ field }) => (
<FormItem>
<FormLabel>{t("masksAndZones.zones.name")}</FormLabel>
<FormLabel>{t("masksAndZones.zones.name.title")}</FormLabel>
<FormControl>
<Input
className="text-md w-full border border-input bg-background p-2 hover:bg-accent hover:text-accent-foreground dark:[color-scheme:dark]"
@@ -553,7 +553,7 @@ export default function ZoneEditPane({
name="inertia"
render={({ field }) => (
<FormItem>
<FormLabel>{t("masksAndZones.zones.inertia")}</FormLabel>
<FormLabel>{t("masksAndZones.zones.inertia.title")}</FormLabel>
<FormControl>
<Input
className="text-md w-full border border-input bg-background p-2 hover:bg-accent hover:text-accent-foreground dark:[color-scheme:dark]"
@@ -576,7 +576,9 @@ export default function ZoneEditPane({
name="loitering_time"
render={({ field }) => (
<FormItem>
<FormLabel>{t("masksAndZones.zones.loiteringTime")}</FormLabel>
<FormLabel>
{t("masksAndZones.zones.loiteringTime.title")}
</FormLabel>
<FormControl>
<Input
className="text-md w-full border border-input bg-background p-2 hover:bg-accent hover:text-accent-foreground dark:[color-scheme:dark]"
@@ -595,7 +597,7 @@ export default function ZoneEditPane({
/>
<Separator className="my-2 flex bg-secondary" />
<FormItem>
<FormLabel>{t("masksAndZones.zones.objects")}</FormLabel>
<FormLabel>{t("masksAndZones.zones.objects.title")}</FormLabel>
<FormDescription>
{t("masksAndZones.zones.objects.desc")}
</FormDescription>
@@ -631,7 +633,7 @@ export default function ZoneEditPane({
className="cursor-pointer text-primary"
htmlFor="allLabels"
>
{t("masksAndZones.zones.speedEstimation")}
{t("masksAndZones.zones.speedEstimation.title")}
</FormLabel>
<Switch
checked={field.value}
@@ -644,7 +646,7 @@ export default function ZoneEditPane({
) {
toast.error(
t(
"masksAndZones.zones.speedEstimation.pointLengthError",
"masksAndZones.zones.speedThreshold.toast.error.pointLengthError",
),
);
return;
@@ -655,7 +657,7 @@ export default function ZoneEditPane({
if (checked && loiteringTime && loiteringTime > 0) {
toast.error(
t(
"masksAndZones.zones.speedEstimation.loiteringTimeError",
"masksAndZones.zones.speedThreshold.toast.error.loiteringTimeError",
),
);
}
@@ -778,11 +780,12 @@ export default function ZoneEditPane({
render={({ field }) => (
<FormItem>
<FormLabel>
{t("masksAndZones.zones.speedThreshold", {
{t("masksAndZones.zones.speedThreshold.title", {
ns: "views/settings",
unit:
config?.ui.unit_system == "imperial"
? t("unit.speed.mph")
: t("unit.speed.kph"),
? t("unit.speed.mph", { ns: "common" })
: t("unit.speed.kph", { ns: "common" }),
})}
</FormLabel>
<FormControl>