Skip to content

Commit 805ee93

Browse files
committed
translations
1 parent a967c12 commit 805ee93

File tree

3 files changed

+70
-26
lines changed

3 files changed

+70
-26
lines changed

client/src/components/checks/CardCheckDetails.tsx

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ import type { MonitorStatus } from "@/types/monitor";
1313
import { formatDateWithTz } from "@/utils/TimeUtils";
1414
import { useTheme } from "@mui/material/styles";
1515
import { getMonitorPath } from "@/utils/MonitorUtils";
16+
import { useTranslation } from "react-i18next";
1617

1718
type CheckDetailsCardProps = {
1819
check: ICheck;
1920
};
2021

2122
export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
23+
const { t } = useTranslation();
2224
const theme = useTheme();
2325
const uiTimezone = useAppSelector((state: any) => state.ui.timezone);
2426
const phases = check?.timings?.phases;
25-
const phaseKeys = [
27+
type phaseKeys = [
2628
"wait",
2729
"dns",
2830
"tcp",
@@ -31,7 +33,7 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
3133
"firstByte",
3234
"download",
3335
"total",
34-
] as const;
36+
];
3537

3638
const status =
3739
(check?.status as MonitorStatus) ?? ("initializing" as MonitorStatus);
@@ -53,7 +55,7 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
5355
? formatDateWithTz(check.createdAt, "ddd, MMM D, YYYY, HH:mm A", uiTimezone)
5456
: "-";
5557
const messageText = check?.message ?? "-";
56-
const getPhaseMs = (key: (typeof phaseKeys)[number]) => {
58+
const getPhaseMs = (key: phaseKeys[number]) => {
5759
const v = Number((phases as any)?.[key] ?? NaN);
5860
return Number.isFinite(v) ? `${Math.floor(Math.max(0, v))} ms` : "-";
5961
};
@@ -62,8 +64,12 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
6264
<BaseBox p={4} flex={1} height={"100%"}>
6365
<Stack spacing={8} sx={{ width: "100%" }}>
6466
<Stack>
65-
<Typography>Check details</Typography>
66-
<Typography variant="body2">{`Total request time: ${getPhaseMs("total")}`}</Typography>
67+
<Typography>{t("checks.details.detailsCard.title")}</Typography>
68+
<Typography variant="body2">
69+
{t("checks.details.common.requestTime", {
70+
time: getPhaseMs("total"),
71+
})}
72+
</Typography>
6773
{(() => {
6874
const href = `/${getMonitorPath(check.metadata.type)}/${check.metadata.monitorId}`;
6975
return href ? (
@@ -74,7 +80,7 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
7480
underline="hover"
7581
color="primary"
7682
>
77-
View monitor details
83+
{t("checks.details.detailsCard.linkText")}
7884
</Link>
7985
</Typography>
8086
) : null;
@@ -89,11 +95,13 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
8995
mt={4}
9096
mb={2}
9197
>
92-
<Typography>Basic check info</Typography>
98+
<Typography>
99+
{t("checks.details.detailsCard.headers.basicInfo")}
100+
</Typography>
93101
</Grid>
94102
<Grid size={6} sx={{ display: "flex", alignItems: "center" }}>
95103
<Typography variant="body1" color="text.secondary">
96-
Status
104+
{t("checks.details.detailsCard.fields.status")}
97105
</Typography>
98106
</Grid>
99107
<Grid size={6} sx={{ display: "flex", alignItems: "center" }}>
@@ -103,7 +111,7 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
103111
</Grid>
104112
<Grid size={6} sx={{ display: "flex", alignItems: "center" }}>
105113
<Typography variant="body1" color="text.secondary">
106-
HTTP Code
114+
{t("checks.details.detailsCard.fields.code")}
107115
</Typography>
108116
</Grid>
109117
<Grid size={6} sx={{ display: "flex", alignItems: "center" }}>
@@ -113,7 +121,7 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
113121
</Grid>
114122
<Grid size={6}>
115123
<Typography variant="body1" color="text.secondary">
116-
Type
124+
{t("checks.details.detailsCard.fields.type")}
117125
</Typography>
118126
</Grid>
119127
<Grid size={6}>
@@ -122,15 +130,15 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
122130

123131
<Grid size={6}>
124132
<Typography variant="body1" color="text.secondary">
125-
Check time
133+
{t("checks.details.detailsCard.fields.checkTime")}
126134
</Typography>
127135
</Grid>
128136
<Grid size={6}>
129137
<Typography variant="body2">{checkedAtText}</Typography>
130138
</Grid>
131139
<Grid size={6}>
132140
<Typography variant="body1" color="text.secondary">
133-
Message
141+
{t("checks.details.detailsCard.fields.message")}
134142
</Typography>
135143
</Grid>
136144
<Grid size={6}>
@@ -146,12 +154,14 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
146154
mb={4}
147155
mt={2}
148156
>
149-
<Typography>Timing phases</Typography>
157+
<Typography>
158+
{t("checks.details.detailsCard.headers.timing")}
159+
</Typography>
150160
</Grid>
151161

152162
<Grid size={6}>
153163
<Typography variant="body1" color="text.secondary">
154-
Wait
164+
{t("checks.details.detailsCard.fields.wait")}
155165
</Typography>
156166
</Grid>
157167
<Grid size={6}>
@@ -160,7 +170,7 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
160170

161171
<Grid size={6}>
162172
<Typography variant="body1" color="text.secondary">
163-
DNS
173+
{t("checks.details.detailsCard.fields.dns")}
164174
</Typography>
165175
</Grid>
166176
<Grid size={6}>
@@ -169,7 +179,7 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
169179

170180
<Grid size={6}>
171181
<Typography variant="body1" color="text.secondary">
172-
TCP
182+
{t("checks.details.detailsCard.fields.tcp")}
173183
</Typography>
174184
</Grid>
175185
<Grid size={6}>
@@ -178,7 +188,7 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
178188

179189
<Grid size={6}>
180190
<Typography variant="body1" color="text.secondary">
181-
TLS
191+
{t("checks.details.detailsCard.fields.tls")}
182192
</Typography>
183193
</Grid>
184194
<Grid size={6}>
@@ -187,7 +197,7 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
187197

188198
<Grid size={6}>
189199
<Typography variant="body1" color="text.secondary">
190-
Request
200+
{t("checks.details.detailsCard.fields.request")}
191201
</Typography>
192202
</Grid>
193203
<Grid size={6}>
@@ -196,7 +206,7 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
196206

197207
<Grid size={6}>
198208
<Typography variant="body1" color="text.secondary">
199-
First Byte
209+
{t("checks.details.detailsCard.fields.firstByte")}
200210
</Typography>
201211
</Grid>
202212
<Grid size={6}>
@@ -205,7 +215,7 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
205215

206216
<Grid size={6}>
207217
<Typography variant="body1" color="text.secondary">
208-
Download
218+
{t("checks.details.detailsCard.fields.download")}
209219
</Typography>
210220
</Grid>
211221
<Grid size={6}>
@@ -214,7 +224,7 @@ export const CheckDetailsCard = ({ check }: CheckDetailsCardProps) => {
214224

215225
<Grid size={6}>
216226
<Typography variant="body1" color="text.secondary">
217-
Total
227+
{t("checks.details.detailsCard.fields.total")}
218228
</Typography>
219229
</Grid>
220230
<Grid size={6}>

client/src/components/checks/ChartTiming.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Typography from "@mui/material/Typography";
55
import { alpha, useTheme } from "@mui/material/styles";
66
import { useState } from "react";
77
import { BaseBox } from "@/components/design-elements";
8-
8+
import { useTranslation } from "react-i18next";
99
type TimingsChartProps = { check: ICheck | null };
1010

1111
export type TimingSegment = {
@@ -41,11 +41,11 @@ const buildTimingSegments = (
4141
};
4242

4343
export const TimingsChart = ({ check }: TimingsChartProps) => {
44-
if (!check) return null;
45-
4644
const theme = useTheme();
45+
const { t } = useTranslation();
4746
const strokeColor = alpha(theme.palette.primary.main, 0.8);
4847
const [hoveredIndex, setHoveredIndex] = useState<number | null>(null);
48+
if (!check) return null;
4949
const segments = buildTimingSegments(
5050
check?.timings?.phases,
5151
strokeColor,
@@ -57,9 +57,11 @@ export const TimingsChart = ({ check }: TimingsChartProps) => {
5757
return (
5858
<BaseBox p={4} flex={1} height={"100%"}>
5959
<Stack spacing={2} sx={{ width: "100%", height: 400 }}>
60-
<Typography>Request timings</Typography>
60+
<Typography>{t("checks.details.timingChart.title")}</Typography>
6161
<Typography variant="body2">
62-
{`Total request time: ${Math.floor(Number(check?.timings?.phases?.total ?? 0))} ms`}
62+
{t("checks.details.common.requestTime", {
63+
time: `${Math.floor(Number(check?.timings?.phases?.total ?? 0))} ms`,
64+
})}
6365
</Typography>
6466
<ResponsiveContainer width="100%" height="100%">
6567
<PieChart>

client/src/locales/en.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,38 @@
115115
"dateTime": "Date & Time",
116116
"statusCode": "Status code"
117117
}
118+
},
119+
"details": {
120+
"common": {
121+
"requestTime": "Total request time: {{time}}"
122+
},
123+
"detailsCard": {
124+
"title": "Check details",
125+
"linkText": "View monitor",
126+
"headers": {
127+
"basicInfo": "Basic check info",
128+
"timing": "Timing phases"
129+
},
130+
"fields": {
131+
"status": "Status",
132+
"code": "HTTP Code",
133+
"type": "Type",
134+
"checkTime": "Check time",
135+
"message": "Message",
136+
"timingPhases": "Timing phases",
137+
"wait": "Wait",
138+
"dns": "DNS",
139+
"tcp": "TCP",
140+
"tls": "TLS",
141+
"request": "Request",
142+
"firstByte": "First byte",
143+
"download": "Download",
144+
"total": "Total"
145+
}
146+
},
147+
"timingChart": {
148+
"title": "Request timings"
149+
}
118150
}
119151
},
120152
"common": {

0 commit comments

Comments
 (0)