Skip to content

Commit 01a4315

Browse files
committed
translations for currently running command, notifications badge and page
1 parent 16b0506 commit 01a4315

File tree

14 files changed

+283
-62
lines changed

14 files changed

+283
-62
lines changed

src/components/etke.cc/CurrentlyRunningCommand.tsx

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { Stack, Tooltip, Typography, Box, Link } from "@mui/material";
2-
import { useStore } from "react-admin";
1+
import EngineeringIcon from "@mui/icons-material/Engineering";
2+
import { Tooltip, Typography, Link, Alert } from "@mui/material";
3+
import { useStore, useTranslate } from "react-admin";
34

45
import { EtkeAttribution } from "./EtkeAttribution";
56
import { GetInstanceConfig } from "./InstanceConfig";
67
import { ServerProcessResponse } from "../../synapse/dataProvider";
78
import { getTimeSince } from "../../utils/date";
89

910
const CurrentlyRunningCommand = () => {
11+
const translate = useTranslate();
1012
const [serverProcess, _setServerProcess] = useStore<ServerProcessResponse>("serverProcess", {
1113
command: "",
1214
locked_at: "",
@@ -19,25 +21,25 @@ const CurrentlyRunningCommand = () => {
1921
}
2022

2123
const icfg = GetInstanceConfig();
24+
const { timeI18Nkey, timeI18Nparams } = getTimeSince(locked_at);
25+
const timeSince = translate(timeI18Nkey, timeI18Nparams);
2226
return (
23-
<Stack spacing={1} direction="row" alignItems="center">
24-
<Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
25-
<Typography variant="h5">Currently running:</Typography>
26-
<Typography variant="h5" color="text.secondary">
27-
{icfg.disabled.attributions && <Typography>{command}</Typography>}
28-
<EtkeAttribution>
29-
<Link href={"https://etke.cc/help/extras/scheduler/#" + command} target="_blank">
30-
{command}
31-
</Link>
32-
</EtkeAttribution>
33-
<Tooltip title={locked_at.toString()}>
34-
<Typography component="span" color="text.secondary" sx={{ display: "inline-block", ml: 1 }}>
35-
(started {getTimeSince(locked_at)} ago)
36-
</Typography>
37-
</Tooltip>
38-
</Typography>
39-
</Box>
40-
</Stack>
27+
<Alert icon={<EngineeringIcon />} severity="warning">
28+
<Typography variant="h5">
29+
{translate("etkecc.currently_running.command")}{" "}
30+
{icfg.disabled.attributions && <Typography>{command}</Typography>}
31+
<EtkeAttribution>
32+
<Link href={"https://etke.cc/help/extras/scheduler/#" + command} target="_blank">
33+
{command}
34+
</Link>
35+
</EtkeAttribution>
36+
<Tooltip title={locked_at.toString()}>
37+
<Typography component="span" color="text.secondary" sx={{ display: "inline-block", ml: 1 }}>
38+
{translate("etkecc.currently_running.started_ago", { time: timeSince })}
39+
</Typography>
40+
</Tooltip>
41+
</Typography>
42+
</Alert>
4143
);
4244
};
4345

src/components/etke.cc/ServerNotificationsBadge.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
Tooltip,
1919
} from "@mui/material";
2020
import { Fragment, useEffect, useState } from "react";
21-
import { useDataProvider, useStore } from "react-admin";
21+
import { useDataProvider, useStore, useTranslate } from "react-admin";
2222
import { useNavigate } from "react-router";
2323

2424
import { useAppContext } from "../../Context";
@@ -97,6 +97,7 @@ export const ServerNotificationsBadge = () => {
9797
const navigate = useNavigate();
9898
const { success, notifications, deleteServerNotifications } = useServerNotifications();
9999
const theme = useTheme();
100+
const translate = useTranslate();
100101

101102
// Modify menu state to work with Popper
102103
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
@@ -130,8 +131,8 @@ export const ServerNotificationsBadge = () => {
130131
<Tooltip
131132
title={
132133
notifications && notifications.length > 0
133-
? `${notifications.length} new notifications`
134-
: `No notifications yet`
134+
? translate("etkecc.notifications.new_notifications", { smart_count: notifications.length })
135+
: translate("etkecc.notifications.no_notifications")
135136
}
136137
>
137138
{(notifications && notifications.length > 0 && (
@@ -159,7 +160,7 @@ export const ServerNotificationsBadge = () => {
159160
>
160161
{!notifications || notifications.length === 0 ? (
161162
<Typography sx={{ p: 1 }} variant="body2">
162-
No new notifications
163+
{translate("etkecc.notifications.no_notifications")}
163164
</Typography>
164165
) : (
165166
<List sx={{ p: 0 }} dense={true}>
@@ -171,16 +172,17 @@ export const ServerNotificationsBadge = () => {
171172
fontWeight: "bold",
172173
}}
173174
>
174-
<Typography variant="h6">Notifications</Typography>
175+
<Typography variant="h6">{translate("etkecc.notifications.title")}</Typography>
175176
<Box
176177
sx={{ cursor: "pointer", color: theme.palette.primary.main }}
177178
onClick={() => handleSeeAllNotifications()}
178179
>
179-
See all notifications
180+
{translate("etkecc.notifications.see_all")}
180181
</Box>
181182
</ListSubheader>
182183
<Divider />
183184
{notifications.map((notification, index) => {
185+
const { timeI18Nkey, timeI18Nparams } = getTimeSince(notification.sent_at);
184186
return (
185187
<Fragment key={notification.event_id ? notification.event_id + index : index}>
186188
<ListItem
@@ -211,7 +213,7 @@ export const ServerNotificationsBadge = () => {
211213
<ListItemText
212214
primary={
213215
<Typography variant="body2" sx={{ color: theme.palette.text.secondary }}>
214-
{getTimeSince(notification.sent_at) + " ago"}
216+
{translate(timeI18Nkey, timeI18Nparams) + " " + translate("etkecc.notifications.ago")}
215217
</Typography>
216218
}
217219
/>
@@ -233,7 +235,7 @@ export const ServerNotificationsBadge = () => {
233235
}}
234236
>
235237
<DeleteIcon fontSize="small" sx={{ mr: 1 }} />
236-
Clear all
238+
{translate("etkecc.notifications.clear_all")}
237239
</Button>
238240
</ListItem>
239241
</List>

src/components/etke.cc/ServerNotificationsPage.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,15 @@ import DeleteIcon from "@mui/icons-material/Delete";
22
import { Box, Typography, Paper, Button } from "@mui/material";
33
import { Stack } from "@mui/material";
44
import { Tooltip } from "@mui/material";
5-
import { useLocale, useStore } from "react-admin";
5+
import { useLocale, useStore, useTranslate } from "react-admin";
66

77
import { useAppContext } from "../../Context";
88
import dataProvider, { ServerNotificationsResponse } from "../../synapse/dataProvider";
99
import { getTimeSince } from "../../utils/date";
1010

11-
const DisplayTime = ({ date, locale }: { date: string; locale: string }) => {
12-
const dateFromDateString = new Date(date.replace(" ", "T") + "Z");
13-
return (
14-
<Tooltip title={dateFromDateString.toLocaleString(locale)}>{<span>{getTimeSince(date) + " ago"}</span>}</Tooltip>
15-
);
16-
};
17-
1811
const ServerNotificationsPage = () => {
1912
const locale = useLocale();
13+
const translate = useTranslate();
2014
const { etkeccAdmin } = useAppContext();
2115
const [serverNotifications, setServerNotifications] = useStore<ServerNotificationsResponse>("serverNotifications", {
2216
notifications: [],
@@ -29,7 +23,7 @@ const ServerNotificationsPage = () => {
2923
<Stack spacing={3} mt={3}>
3024
<Stack spacing={1} direction="row" alignItems="center">
3125
<Box sx={{ display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%", gap: 1 }}>
32-
<Typography variant="h4">Server Notifications</Typography>
26+
<Typography variant="h4">{translate("etkecc.notifications.title")}</Typography>
3327
<Button
3428
variant="text"
3529
color="error"
@@ -41,26 +35,32 @@ const ServerNotificationsPage = () => {
4135
});
4236
}}
4337
>
44-
<DeleteIcon fontSize="small" sx={{ mr: 1 }} /> Clear
38+
<DeleteIcon fontSize="small" sx={{ mr: 1 }} /> {translate("etkecc.notifications.clear_all")}
4539
</Button>
4640
</Box>
4741
</Stack>
4842

4943
{notifications.length === 0 ? (
5044
<Paper sx={{ p: 2 }}>
51-
<Typography>No new notifications.</Typography>
45+
<Typography>{translate("etkecc.notifications.no_notifications")}</Typography>
5246
</Paper>
5347
) : (
54-
notifications.map((notification, index) => (
55-
<Paper key={notification.event_id ? notification.event_id : index} sx={{ p: 2 }}>
56-
<Stack spacing={1}>
57-
<Typography variant="subtitle1" fontWeight="bold" color="text.secondary">
58-
<DisplayTime date={notification.sent_at} locale={locale} />
59-
</Typography>
60-
<Typography dangerouslySetInnerHTML={{ __html: notification.output }} />
61-
</Stack>
62-
</Paper>
63-
))
48+
notifications.map((notification, index) => {
49+
const { timeI18Nkey, timeI18Nparams } = getTimeSince(notification.sent_at);
50+
const tooltipTitle = new Date(notification.sent_at.replace(" ", "T") + "Z").toLocaleString(locale);
51+
return (
52+
<Paper key={notification.event_id ? notification.event_id : index} sx={{ p: 2 }}>
53+
<Stack spacing={1}>
54+
<Typography variant="subtitle1" fontWeight="bold" color="text.secondary">
55+
<Tooltip title={tooltipTitle}>
56+
<span>{translate(timeI18Nkey, timeI18Nparams) + " " + translate("etkecc.notifications.ago")}</span>
57+
</Tooltip>
58+
</Typography>
59+
<Typography dangerouslySetInnerHTML={{ __html: notification.output }} />
60+
</Stack>
61+
</Paper>
62+
);
63+
})
6464
)}
6565
</Stack>
6666
);

src/i18n/de.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,27 @@ const de: SynapseTranslationMessages = {
573573
try_again: "Bitte versuchen Sie es später erneut.",
574574
note: "Sie müssen den Support hierzu nicht kontaktieren — wir arbeiten bereits daran!",
575575
},
576+
notifications: {
577+
title: "Benachrichtigungen",
578+
new_notifications: "%{smart_count} neue Benachrichtigung |||| %{smart_count} neue Benachrichtigungen",
579+
no_notifications: "Noch keine Benachrichtigungen",
580+
see_all: "Alle Benachrichtigungen anzeigen",
581+
clear_all: "Alle löschen",
582+
ago: "vor",
583+
},
584+
currently_running: {
585+
command: "Derzeit läuft:",
586+
started_ago: "(vor %{time} gestartet)",
587+
},
588+
time: {
589+
less_than_minute: "ein paar Sekunden",
590+
minutes: "%{smart_count} Minute |||| %{smart_count} Minuten",
591+
hours: "%{smart_count} Stunde |||| %{smart_count} Stunden",
592+
days: "%{smart_count} Tag |||| %{smart_count} Tage",
593+
weeks: "%{smart_count} Woche |||| %{smart_count} Wochen",
594+
months: "%{smart_count} Monat |||| %{smart_count} Monate",
595+
},
576596
},
577-
578597
scheduled_commands: {
579598
action: {
580599
create_success: "Geplanter Befehl erfolgreich erstellt.",

src/i18n/en.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,26 @@ const en: SynapseTranslationMessages = {
541541
try_again: "Please try again later.",
542542
note: "You don't need to contact support about this, we are already working on it!",
543543
},
544+
notifications: {
545+
title: "Notifications",
546+
new_notifications: "%{smart_count} new notification |||| %{smart_count} new notifications",
547+
no_notifications: "No notifications yet",
548+
see_all: "See all notifications",
549+
clear_all: "Clear all",
550+
ago: "ago",
551+
},
552+
currently_running: {
553+
command: "Currently running:",
554+
started_ago: "(started %{time} ago)",
555+
},
556+
time: {
557+
less_than_minute: "a couple of seconds",
558+
minutes: "%{smart_count} minute |||| %{smart_count} minutes",
559+
hours: "%{smart_count} hour |||| %{smart_count} hours",
560+
days: "%{smart_count} day |||| %{smart_count} days",
561+
weeks: "%{smart_count} week |||| %{smart_count} weeks",
562+
months: "%{smart_count} month |||| %{smart_count} months",
563+
},
544564
},
545565
scheduled_commands: {
546566
action: {

src/i18n/fa.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,26 @@ const fa: SynapseTranslationMessages = {
511511
try_again: "لطفاً بعداً دوباره تلاش کنید.",
512512
note: "نیازی نیست بابت این موضوع با پشتیبانی تماس بگیرید؛ ما از قبل در حال رسیدگی هستیم!",
513513
},
514+
notifications: {
515+
title: "اعلان‌ها",
516+
new_notifications: "%{smart_count} اعلان جدید",
517+
no_notifications: "هنوز اعلانی وجود ندارد",
518+
see_all: "مشاهده همه اعلان‌ها",
519+
clear_all: "حذف همه",
520+
ago: "پیش",
521+
},
522+
currently_running: {
523+
command: "در حال اجرا:",
524+
started_ago: "(از %{time} پیش شروع شده)",
525+
},
526+
time: {
527+
less_than_minute: "چند ثانیه",
528+
minutes: "%{smart_count} دقیقه",
529+
hours: "%{smart_count} ساعت",
530+
days: "%{smart_count} روز",
531+
weeks: "%{smart_count} هفته",
532+
months: "%{smart_count} ماه",
533+
},
514534
},
515535
};
516536
export default fa;

src/i18n/fr.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,26 @@ const fr: SynapseTranslationMessages = {
508508
try_again: "Veuillez réessayer plus tard.",
509509
note: "Vous n’avez pas besoin de contacter le support à ce sujet : nous nous en occupons déjà !",
510510
},
511+
notifications: {
512+
title: "Notifications",
513+
new_notifications: "%{smart_count} nouvelle notification |||| %{smart_count} nouvelles notifications",
514+
no_notifications: "Aucune notification pour le moment",
515+
see_all: "Voir toutes les notifications",
516+
clear_all: "Tout effacer",
517+
ago: "il y a",
518+
},
519+
currently_running: {
520+
command: "En cours d’exécution :",
521+
started_ago: "(démarré il y a %{time})",
522+
},
523+
time: {
524+
less_than_minute: "quelques secondes",
525+
minutes: "%{smart_count} minute |||| %{smart_count} minutes",
526+
hours: "%{smart_count} heure |||| %{smart_count} heures",
527+
days: "%{smart_count} jour |||| %{smart_count} jours",
528+
weeks: "%{smart_count} semaine |||| %{smart_count} semaines",
529+
months: "%{smart_count} mois |||| %{smart_count} mois",
530+
},
511531
},
512532
};
513533
export default fr;

src/i18n/index.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,26 @@ interface SynapseTranslationMessages extends TranslationMessages {
520520
try_again: string;
521521
note: string;
522522
};
523+
notifications: {
524+
title: string;
525+
new_notifications: string;
526+
no_notifications: string;
527+
see_all: string;
528+
clear_all: string;
529+
ago: string;
530+
};
531+
currently_running: {
532+
command: string;
533+
started_ago: string;
534+
};
535+
time: {
536+
less_than_minute: string;
537+
minutes: string;
538+
hours: string;
539+
days: string;
540+
weeks: string;
541+
months: string;
542+
};
523543
};
524544
scheduled_commands?: {
525545
action: {

src/i18n/it.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,26 @@ const it: SynapseTranslationMessages = {
506506
try_again: "Riprova più tardi.",
507507
note: "Non è necessario contattare l’assistenza per questo: ci stiamo già lavorando!",
508508
},
509+
notifications: {
510+
title: "Notifiche",
511+
new_notifications: "%{smart_count} nuova notifica |||| %{smart_count} nuove notifiche",
512+
no_notifications: "Nessuna notifica per ora",
513+
see_all: "Vedi tutte le notifiche",
514+
clear_all: "Cancella tutto",
515+
ago: "fa",
516+
},
517+
currently_running: {
518+
command: "Attualmente in esecuzione:",
519+
started_ago: "(avviato %{time} fa)",
520+
},
521+
time: {
522+
less_than_minute: "qualche secondo",
523+
minutes: "%{smart_count} minuto |||| %{smart_count} minuti",
524+
hours: "%{smart_count} ora |||| %{smart_count} ore",
525+
days: "%{smart_count} giorno |||| %{smart_count} giorni",
526+
weeks: "%{smart_count} settimana |||| %{smart_count} settimane",
527+
months: "%{smart_count} mese |||| %{smart_count} mesi",
528+
},
509529
},
510530
};
511531
export default it;

0 commit comments

Comments
 (0)