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.
This commit is contained in:
@@ -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)}
|
||||
</div>
|
||||
|
||||
<div style={styles.statusCell}>
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user