From 3a574b2f4ed0f34c0c6ab126529faddf03f20e6c Mon Sep 17 00:00:00 2001 From: mohadeseh safari Date: Fri, 9 May 2025 14:40:07 -0400 Subject: [PATCH 1/5] translate menu items --- client/src/Components/Sidebar/index.jsx | 44 ++++++++++++---------- client/src/Pages/Uptime/Monitors/index.jsx | 7 +++- client/src/locales/gb.json | 25 +++++++++++- client/src/locales/ru.json | 25 +++++++++++- client/src/locales/tr.json | 23 +++++++++++ 5 files changed, 101 insertions(+), 23 deletions(-) diff --git a/client/src/Components/Sidebar/index.jsx b/client/src/Components/Sidebar/index.jsx index 81edcd3cc..dd548476a 100644 --- a/client/src/Components/Sidebar/index.jsx +++ b/client/src/Components/Sidebar/index.jsx @@ -47,46 +47,47 @@ import "./index.css"; import { useLocation, useNavigate } from "react-router"; import { useTheme } from "@emotion/react"; import { useDispatch, useSelector } from "react-redux"; +import { useTranslation } from "react-i18next"; import { clearAuthState } from "../../Features/Auth/authSlice"; import { toggleSidebar } from "../../Features/UI/uiSlice"; import { clearUptimeMonitorState } from "../../Features/UptimeMonitors/uptimeMonitorsSlice"; -const menu = [ - { name: "Uptime", path: "uptime", icon: }, - { name: "Pagespeed", path: "pagespeed", icon: }, - { name: "Infrastructure", path: "infrastructure", icon: }, +const getMenu = (t) => [ + { name: t("menu.uptime"), path: "uptime", icon: }, + { name: t("menu.pagespeed"), path: "pagespeed", icon: }, + { name: t("menu.infrastructure"), path: "infrastructure", icon: }, { - name: "Distributed uptime", + name: t("menu.distributedUptime"), path: "distributed-uptime", icon: , }, - { name: "Incidents", path: "incidents", icon: }, + { name: t("menu.incidents"), path: "incidents", icon: }, - { name: "Status pages", path: "status", icon: }, - { name: "Maintenance", path: "maintenance", icon: }, - // { name: "Integrations", path: "integrations", icon: }, + { name: t("menu.statusPages"), path: "status", icon: }, + { name: t("menu.maintenance"), path: "maintenance", icon: }, + // { name: t("menu.integrations"), path: "integrations", icon: }, { - name: "Settings", + name: t("menu.settings"), icon: , path: "settings", }, ]; -const otherMenuItems = [ - { name: "Support", path: "support", icon: }, +const getOtherMenuItems = (t) => [ + { name: t("menu.support"), path: "support", icon: }, { - name: "Discussions", + name: t("menu.discussions"), path: "discussions", icon: , }, - { name: "Docs", path: "docs", icon: }, - { name: "Changelog", path: "changelog", icon: }, + { name: t("menu.docs"), path: "docs", icon: }, + { name: t("menu.changelog"), path: "changelog", icon: }, ]; -const accountMenuItems = [ - { name: "Profile", path: "account/profile", icon: }, - { name: "Password", path: "account/password", icon: }, - { name: "Team", path: "account/team", icon: }, +const getAccountMenuItems = (t) => [ + { name: t("menu.profile"), path: "account/profile", icon: }, + { name: t("menu.password"), path: "account/password", icon: }, + { name: t("menu.team"), path: "account/team", icon: }, ]; /* TODO this could be a key in nested Path would be the link */ @@ -118,7 +119,12 @@ function Sidebar() { const navigate = useNavigate(); const location = useLocation(); const dispatch = useDispatch(); + const { t } = useTranslation(); const authState = useSelector((state) => state.auth); + + const menu = getMenu(t); + const otherMenuItems = getOtherMenuItems(t); + const accountMenuItems = getAccountMenuItems(t); const collapsed = useSelector((state) => state.ui.sidebar.collapsed); const [open, setOpen] = useState({ Dashboard: false, Account: false, Other: false }); const [anchorEl, setAnchorEl] = useState(null); diff --git a/client/src/Pages/Uptime/Monitors/index.jsx b/client/src/Pages/Uptime/Monitors/index.jsx index 60a308141..ce9123816 100644 --- a/client/src/Pages/Uptime/Monitors/index.jsx +++ b/client/src/Pages/Uptime/Monitors/index.jsx @@ -31,11 +31,11 @@ import PropTypes from "prop-types"; import useFetchMonitorsWithSummary from "../../../Hooks/useFetchMonitorsWithSummary"; import useFetchMonitorsWithChecks from "../../../Hooks/useFetchMonitorsWithChecks"; import { useTranslation } from "react-i18next"; -const BREADCRUMBS = [{ name: `Uptime`, path: "/uptime" }]; const TYPES = ["http", "ping", "docker", "port"]; const CreateMonitorButton = ({ shouldRender }) => { // Utils const navigate = useNavigate(); + const { t } = useTranslation(); if (shouldRender === false) { return; } @@ -49,7 +49,7 @@ const CreateMonitorButton = ({ shouldRender }) => { navigate("/uptime/create"); }} > - Create new + {t("createNew")} ); @@ -78,10 +78,13 @@ const UptimeMonitors = () => { // Utils const theme = useTheme(); + const navigate = useNavigate(); const isAdmin = useIsAdmin(); const dispatch = useDispatch(); const { t } = useTranslation(); + const BREADCRUMBS = [{ name: t("menu.uptime"), path: "/uptime" }]; + // Handlers const handleChangePage = (event, newPage) => { setPage(newPage); diff --git a/client/src/locales/gb.json b/client/src/locales/gb.json index 49993eb89..dacf84eb8 100644 --- a/client/src/locales/gb.json +++ b/client/src/locales/gb.json @@ -439,6 +439,29 @@ "pageSpeedApiKeyFieldLabel": "PageSpeed API key", "pageSpeedApiKeyFieldDescription": "Enter your Google PageSpeed API key to enable pagespeed monitoring. Click Reset to update the key.", "pageSpeedApiKeyFieldResetLabel": "API key is set. Click Reset to change it.", - "reset": "Reset" + "reset": "Reset", + "createNew": "Create new", + "monitorState": { + "paused": "paused", + "resumed": "resumed" + }, + "menu": { + "uptime": "Uptime", + "pagespeed": "Pagespeed", + "infrastructure": "Infrastructure", + "distributedUptime": "Distributed uptime", + "incidents": "Incidents", + "statusPages": "Status pages", + "maintenance": "Maintenance", + "integrations": "Integrations", + "settings": "Settings", + "support": "Support", + "discussions": "Discussions", + "docs": "Docs", + "changelog": "Changelog", + "profile": "Profile", + "password": "Password", + "team": "Team" + } } diff --git a/client/src/locales/ru.json b/client/src/locales/ru.json index 5536b5e45..a37923557 100644 --- a/client/src/locales/ru.json +++ b/client/src/locales/ru.json @@ -393,5 +393,28 @@ "maintenanceTableActionMenuDialogTitle": "", "pageSpeedWarning": "Предупреждение: Вы не добавили ключ API Google PageSpeed. Без него монитор PageSpeed не будет работать.", "pageSpeedLearnMoreLink": "Нажмите здесь, чтобы узнать", - "pageSpeedAddApiKey": "как добавить ваш ключ API." + "pageSpeedAddApiKey": "как добавить ваш ключ API.", + "createNew": "Создать новый", + "monitorState": { + "paused": "приостановлен", + "resumed": "возобновлен" + }, + "menu": { + "uptime": "Аптайм", + "pagespeed": "Скорость страницы", + "infrastructure": "Инфраструктура", + "distributedUptime": "Распределенный аптайм", + "incidents": "Инциденты", + "statusPages": "Страницы статуса", + "maintenance": "Обслуживание", + "integrations": "Интеграции", + "settings": "Настройки", + "support": "Поддержка", + "discussions": "Обсуждения", + "docs": "Документация", + "changelog": "История изменений", + "profile": "Профиль", + "password": "Пароль", + "team": "Команда" + } } \ No newline at end of file diff --git a/client/src/locales/tr.json b/client/src/locales/tr.json index 5df644fdd..e7e95a339 100644 --- a/client/src/locales/tr.json +++ b/client/src/locales/tr.json @@ -427,5 +427,28 @@ "validationFailed": "", "noFileSelected": "", "fallbackPage": "" + }, + "createNew": "Yeni oluştur", + "monitorState": { + "paused": "duraklatıldı", + "resumed": "devam ettirildi" + }, + "menu": { + "uptime": "Çalışma Süresi", + "pagespeed": "Sayfa Hızı", + "infrastructure": "Altyapı", + "distributedUptime": "Dağıtılmış Çalışma Süresi", + "incidents": "Olaylar", + "statusPages": "Durum Sayfaları", + "maintenance": "Bakım", + "integrations": "Entegrasyonlar", + "settings": "Ayarlar", + "support": "Destek", + "discussions": "Tartışmalar", + "docs": "Belgeler", + "changelog": "Değişiklik Günlüğü", + "profile": "Profil", + "password": "Şifre", + "team": "Takım" } } From 13c4390f967512f7fccd39ee54d621d808136a58 Mon Sep 17 00:00:00 2001 From: mohadeseh safari Date: Fri, 9 May 2025 14:58:13 -0400 Subject: [PATCH 2/5] fix: translate UI elements in menu and uptime page - Added translations for sidebar menu items in all languages - Fixed "Create new" button to use translation instead of hardcoded text - Added missing translations for "Bulk Import" in Russian and Turkish - Translated status box labels (UP, DOWN, PAUSED) in the uptime monitors page - Made greeting component fully translatable with proper context - Fixed lint warnings in components --- .../Components/MonitorCreateHeader/index.jsx | 6 ++-- .../Monitors/Components/StatusBoxes/index.jsx | 9 ++++-- client/src/Utils/greeting.jsx | 8 ++++-- client/src/locales/gb.json | 10 +++++++ client/src/locales/ru.json | 23 ++++++++++++++- client/src/locales/tr.json | 28 +++++++++++++------ 6 files changed, 66 insertions(+), 18 deletions(-) diff --git a/client/src/Components/MonitorCreateHeader/index.jsx b/client/src/Components/MonitorCreateHeader/index.jsx index 05a9b7f9b..15d6d5c0f 100644 --- a/client/src/Components/MonitorCreateHeader/index.jsx +++ b/client/src/Components/MonitorCreateHeader/index.jsx @@ -6,7 +6,7 @@ import { useTheme } from "@emotion/react"; const CreateMonitorHeader = ({ isAdmin, - label = "Create new", + label, isLoading = true, path, bulkPath, @@ -14,6 +14,8 @@ const CreateMonitorHeader = ({ const navigate = useNavigate(); const { t } = useTranslation(); const theme = useTheme(); + + // Use the provided label or fall back to the translated default if (!isAdmin) return null; @@ -30,7 +32,7 @@ const CreateMonitorHeader = ({ color="accent" onClick={() => navigate(path)} > - {label} + {label || t("createNew")} {bulkPath && ( @@ -238,22 +238,20 @@ const TeamPanel = () => { color="accent" onClick={() => setIsOpen(true)} > - Invite a team member + {t("teamPanel.inviteTeamMember")} { marginBottom={SPACING_GAP} type="email" id="input-team-member" - placeholder="Email" + placeholder={t("teamPanel.email")} value={toInvite.email} onChange={handleChange} error={errors.email ? true : false} @@ -270,7 +268,7 @@ const TeamPanel = () => { />