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:
+30
-4
@@ -1,6 +1,7 @@
|
||||
import Link from "next/link";
|
||||
import { query } from "@/lib/db";
|
||||
import { loadMenuEntries } from "@/lib/db/menu-entries";
|
||||
import { loadTranslations } from "@/lib/db/translations";
|
||||
import { getSettings } from "@/lib/db/settings";
|
||||
import {
|
||||
addDays,
|
||||
@@ -33,14 +34,39 @@ export default async function Home({
|
||||
iso: addDays(monday, i),
|
||||
}));
|
||||
|
||||
const [sections, entries, allergens, additives, settings] = await Promise.all([
|
||||
query<Section>("select * from sections order by sort"),
|
||||
const [
|
||||
sectionRows,
|
||||
entries,
|
||||
allergenRows,
|
||||
additiveRows,
|
||||
settings,
|
||||
sectionTranslations,
|
||||
allergenTranslations,
|
||||
additiveTranslations,
|
||||
] = await Promise.all([
|
||||
query<Omit<Section, "translations">>("select key, label, time_range, sort from sections order by sort"),
|
||||
loadMenuEntries(monday, friday),
|
||||
query<CodeItem>("select * from allergens order by sort"),
|
||||
query<CodeItem>("select * from additives order by sort"),
|
||||
query<Omit<CodeItem, "translations">>("select code, name, sort from allergens order by sort"),
|
||||
query<Omit<CodeItem, "translations">>("select code, name, sort from additives order by sort"),
|
||||
getSettings(),
|
||||
loadTranslations("section_translations"),
|
||||
loadTranslations("allergen_translations"),
|
||||
loadTranslations("additive_translations"),
|
||||
]);
|
||||
|
||||
const sections: Section[] = sectionRows.map((s) => ({
|
||||
...s,
|
||||
translations: sectionTranslations.get(s.key) ?? {},
|
||||
}));
|
||||
const allergens: CodeItem[] = allergenRows.map((a) => ({
|
||||
...a,
|
||||
translations: allergenTranslations.get(a.code) ?? {},
|
||||
}));
|
||||
const additives: CodeItem[] = additiveRows.map((a) => ({
|
||||
...a,
|
||||
translations: additiveTranslations.get(a.code) ?? {},
|
||||
}));
|
||||
|
||||
const logo = logoUrl(settings?.logo_path);
|
||||
const labelingDetailed = (settings?.labeling_mode ?? "detailed") !== "notice";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user