From 33caa8f792780ff3bb3622a91d9287fa37912cdf Mon Sep 17 00:00:00 2001 From: nessi Date: Sun, 2 Aug 2026 10:36:44 +0200 Subject: [PATCH] Add entry label translation system for German-to-English game sheet items Implemented `translateEntryLabel` helper function with mapping dictionary for translating German game entry labels (spells, potions, locations) to English equivalents. Added language parameter extraction in SheetSection component and applied translation to entry labels based on current language setting. Maintains German as source labels with English translations provided via lookup table. --- frontend/src/components/SheetSection.jsx | 6 +++--- frontend/src/i18n.jsx | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/SheetSection.jsx b/frontend/src/components/SheetSection.jsx index 39c947c..7fe5225 100644 --- a/frontend/src/components/SheetSection.jsx +++ b/frontend/src/components/SheetSection.jsx @@ -2,7 +2,7 @@ import React from "react"; import { styles } from "../styles/styles"; import { stylesTokens } from "../styles/theme"; -import { useLanguage } from "../i18n"; +import { translateEntryLabel, useLanguage } from "../i18n"; export default function SheetSection({ title, @@ -13,7 +13,7 @@ export default function SheetSection({ displayTag, readOnly = false, }) { - const { t } = useLanguage(); + const { language, t } = useLanguage(); const getRowBg = (status) => { if (status === 1) return stylesTokens.rowNoBg; if (status === 2) return stylesTokens.rowOkBg; @@ -83,7 +83,7 @@ export default function SheetSection({ }} title={readOnly ? t("readOnly") : t("cycleStatus")} > - {e.label} + {translateEntryLabel(e.label, language)}
diff --git a/frontend/src/i18n.jsx b/frontend/src/i18n.jsx index 629e0cd..bf7564a 100644 --- a/frontend/src/i18n.jsx +++ b/frontend/src/i18n.jsx @@ -3,6 +3,28 @@ import React, { createContext, useContext, useEffect, useMemo, useState } from " const STORAGE_KEY = "hpLanguage"; const LanguageContext = createContext(null); +const entryLabels = { + "Schlaftrunk": "Sleeping Potion", + "Verschwindekabinett": "Vanishing Cabinet", + "Portschlüssel": "Portkey", + "Impedimenta": "Impedimenta", + "Petrificus Totalus": "Petrificus Totalus", + "Alraune": "Mandrake", + "Große Halle": "Great Hall", + "Krankenflügel": "Hospital Wing", + "Raum der Wünsche": "Room of Requirement", + "Klassenzimmer für Zaubertränke": "Potions Classroom", + "Pokalszimmer": "Trophy Room", + "Klassenzimmer für Wahrsagen": "Divination Classroom", + "Eulerei": "Owlery", + "Bibliothek": "Library", + "Verteidigung gegen die dunklen Künste": "Defence Against the Dark Arts", +}; + +export function translateEntryLabel(label, language) { + return language === "en" ? (entryLabels[label] || label) : label; +} + export const translations = { de: { language: "Deutsch",