From 757b316b495751ee2982070fe28fa6d65f9f48b2 Mon Sep 17 00:00:00 2001 From: Theis Gaedigk Date: Mon, 9 Feb 2026 13:42:19 +0100 Subject: [PATCH] fixed translation bug --- FrontendV2/src/utils/Fetcher.ts | 10 ++++++---- FrontendV2/src/utils/i18n/locales/de/de.json | 1 + FrontendV2/src/utils/i18n/locales/en/en.json | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/FrontendV2/src/utils/Fetcher.ts b/FrontendV2/src/utils/Fetcher.ts index 035de1f..c6be318 100644 --- a/FrontendV2/src/utils/Fetcher.ts +++ b/FrontendV2/src/utils/Fetcher.ts @@ -1,10 +1,13 @@ import Cookies from "js-cookie"; import { API_BASE } from "@/config/api.config"; +import { useTranslation } from "react-i18next"; export const getBorrowableItems = async ( startDate: string, - endDate: string + endDate: string, ) => { + const { t } = useTranslation(); + try { const response = await fetch(`${API_BASE}/api/loans/borrowable-items`, { method: "POST", @@ -21,8 +24,7 @@ export const getBorrowableItems = async ( data: null, status: "error", title: "Server error", - description: - "Ein Fehler ist auf dem Server aufgetreten. Manchmal hilft es, die Seite neu zu laden.", + description: t("serverError"), }; } @@ -48,7 +50,7 @@ export const createLoan = async ( itemIds: number[], startDate: string, endDate: string, - note: string | null + note: string | null, ) => { const response = await fetch(`${API_BASE}/api/loans/createLoan`, { method: "POST", diff --git a/FrontendV2/src/utils/i18n/locales/de/de.json b/FrontendV2/src/utils/i18n/locales/de/de.json index 5d39c80..f6ed2dc 100644 --- a/FrontendV2/src/utils/i18n/locales/de/de.json +++ b/FrontendV2/src/utils/i18n/locales/de/de.json @@ -84,6 +84,7 @@ "contact": "Kontakt", "take": "Abholen", "return": "Zurückgeben", + "serverError": "Serverfehler. Bitte versuchen Sie es später erneut, oder laden Sie die Seite neu.", "take-loan-success": "Ausleihe erfolgreich abgeholt", "return-loan-success": "Ausleihe erfolgreich zurückgegeben", "network-error": "Netzwerkfehler. Kontaktieren Sie den Administrator.", diff --git a/FrontendV2/src/utils/i18n/locales/en/en.json b/FrontendV2/src/utils/i18n/locales/en/en.json index 13dec04..6a52916 100644 --- a/FrontendV2/src/utils/i18n/locales/en/en.json +++ b/FrontendV2/src/utils/i18n/locales/en/en.json @@ -82,6 +82,7 @@ "contactPage_messagePlaceholder": "Enter your message here...", "contactPage_messageErrorText": "This field cannot be empty.", "contact": "Contact", + "serverError": "Server error. Please try again later, or refresh the page.", "take": "Take", "return": "Return", "take-loan-success": "Loan taken successfully",