feat: Speiseplan-Inhalte variabel mehrsprachig (Teil 2)

Gerichtnamen, Essenszeiten und Allergen-/Zusatzstoff-Bezeichnungen sind
jetzt genauso dynamisch mehrsprachig wie die Bedienoberfläche aus
v1.10.0, statt fest auf Englisch/Polnisch begrenzt zu sein. Neue
Übersetzungstabellen ersetzen die alten name_en/name_pl-Spalten,
DeepL-Auto-Übersetzung und CSV-Import/-Export unterstützen jetzt
beliebig viele aktive Sprachen.
This commit is contained in:
2026-07-20 11:10:06 +02:00
parent 0d69d77d4e
commit cd8b0fab9f
24 changed files with 723 additions and 290 deletions
+21 -7
View File
@@ -12,8 +12,9 @@ export interface Profile {
export interface Section {
key: string;
label: string;
label_en: string | null;
label_pl: string | null;
// Sprachcode (z. B. "en", "fr") -> übersetzter Name. Enthält nie "de" -
// Deutsch ist immer die "label"-Spalte selbst.
translations: Record<string, string>;
time_range: string;
sort: number;
}
@@ -21,8 +22,7 @@ export interface Section {
export interface Dish {
id: string;
name: string;
name_en: string | null;
name_pl: string | null;
translations: Record<string, string>;
price: number;
allergens: string[];
additives: string[];
@@ -39,8 +39,7 @@ export interface MenuEntry {
export interface CodeItem {
code: string;
name: string;
name_en: string | null;
name_pl: string | null;
translations: Record<string, string>;
sort: number;
}
@@ -53,10 +52,25 @@ export interface DishSuggestion {
/** Übersetzten Namen für die aktuelle Sprache liefern, sonst Deutsch als Fallback. */
export function localized(
item: { name?: string; label?: string; name_en?: string | null; name_pl?: string | null; label_en?: string | null; label_pl?: string | null },
item: {
name?: string;
label?: string;
// Neue, dynamische Form (Gerichte/Essenszeiten/Allergene/
// Zusatzstoffe, s. lib/db/translations.ts) – Sprachcode -> Text.
translations?: Record<string, string>;
// Ältere, feste Form – wird u. a. noch für den Hinweistext in den
// Design-Einstellungen genutzt (settings.labeling_notice_en/_pl),
// die kein Übersetzungstabellen-Konzept haben.
name_en?: string | null;
name_pl?: string | null;
label_en?: string | null;
label_pl?: string | null;
},
locale: string
): string {
const de = item.name ?? item.label ?? "";
if (locale === "de") return de;
if (item.translations) return item.translations[locale] || de;
if (locale === "en") return item.name_en || item.label_en || de;
if (locale === "pl") return item.name_pl || item.label_pl || de;
return de;