From 3e4f7c3641378f1e218b736d5a5efbe6aee62388 Mon Sep 17 00:00:00 2001 From: headlessdev Date: Tue, 29 Apr 2025 19:38:48 +0200 Subject: [PATCH] i18n final --- app/dashboard/applications/Applications.tsx | 131 +++---- app/dashboard/network/Networks.tsx | 6 +- app/dashboard/settings/Settings.tsx | 228 +++++------ app/dashboard/uptime/Uptime.tsx | 69 ++-- i18n/languages/de.json | 403 ++++++++++++++++++++ i18n/languages/en.json | 201 ++++++++++ 6 files changed, 797 insertions(+), 241 deletions(-) create mode 100644 i18n/languages/de.json diff --git a/app/dashboard/applications/Applications.tsx b/app/dashboard/applications/Applications.tsx index 979607a..0565efb 100644 --- a/app/dashboard/applications/Applications.tsx +++ b/app/dashboard/applications/Applications.tsx @@ -85,6 +85,7 @@ import { DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; +import { useTranslations } from "next-intl"; interface Application { id: number; @@ -112,6 +113,7 @@ interface ApplicationsResponse { } export default function Dashboard() { + const t = useTranslations(); const [name, setName] = useState(""); const [description, setDescription] = useState(""); const [icon, setIcon] = useState(""); @@ -182,31 +184,28 @@ export default function Dashboard() { }; const handleItemsPerPageChange = (value: string) => { - // Clear any existing timer if (debounceTimerRef.current) { clearTimeout(debounceTimerRef.current); } - // Set a new timer debounceTimerRef.current = setTimeout(() => { const newItemsPerPage = parseInt(value); - // Ensure the value is within the valid range if (isNaN(newItemsPerPage) || newItemsPerPage < 1) { - toast.error("Please enter a number between 1 and 100"); + toast.error(t('Applications.Messages.NumberValidation')); return; } const validatedValue = Math.min(Math.max(newItemsPerPage, 1), 100); setItemsPerPage(validatedValue); - setCurrentPage(1); // Reset to first page when changing items per page + setCurrentPage(1); Cookies.set("itemsPerPage-app", String(validatedValue), { expires: 365, path: "/", sameSite: "strict", }); - }, 300); // 300ms delay + }, 300); }; const add = async () => { @@ -221,10 +220,10 @@ export default function Dashboard() { uptimecheckUrl: customUptimeCheck ? uptimecheckUrl : "", }); getApplications(); - toast.success("Application added successfully"); + toast.success(t('Applications.Messages.AddSuccess')); } catch (error: any) { console.log(error.response?.data); - toast.error("Failed to add application"); + toast.error(t('Applications.Messages.AddError')); } }; @@ -244,7 +243,7 @@ export default function Dashboard() { setLoading(false); } catch (error: any) { console.log(error.response?.data); - toast.error("Failed to get applications"); + toast.error(t('Applications.Messages.GetError')); } }; @@ -265,10 +264,10 @@ export default function Dashboard() { try { await axios.post("/api/applications/delete", { id }); getApplications(); - toast.success("Application deleted successfully"); + toast.success(t('Applications.Messages.DeleteSuccess')); } catch (error: any) { console.log(error.response?.data); - toast.error("Failed to delete application"); + toast.error(t('Applications.Messages.DeleteError')); } }; @@ -306,10 +305,10 @@ export default function Dashboard() { }); getApplications(); setEditId(null); - toast.success("Application edited successfully"); + toast.success(t('Applications.Messages.EditSuccess')); } catch (error: any) { console.log(error.response.data); - toast.error("Failed to edit application"); + toast.error(t('Applications.Messages.EditError')); } }; @@ -363,11 +362,11 @@ export default function Dashboard() { - My Infrastructure + {t('Applications.Breadcrumb.MyInfrastructure')} - Applications + {t('Applications.Breadcrumb.Applications')} @@ -376,11 +375,11 @@ export default function Dashboard() {
- Your Applications + {t('Applications.Title')}
-