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:
@@ -1,14 +1,19 @@
|
||||
import { listCodes } from "@/lib/db/code-lists";
|
||||
import { listActiveLanguageCodes } from "@/lib/db/languages";
|
||||
import { authErrorResponse, requireRole } from "@/lib/auth/session";
|
||||
import { toCsv } from "@/lib/csv";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
await requireRole(["staff", "admin"]);
|
||||
const items = await listCodes("allergens");
|
||||
const [items, activeCodes] = await Promise.all([
|
||||
listCodes("allergens"),
|
||||
listActiveLanguageCodes(),
|
||||
]);
|
||||
const langCodes = activeCodes.filter((c) => c !== "de");
|
||||
const rows = [
|
||||
["code", "name", "name_en", "name_pl"],
|
||||
...items.map((i) => [i.code, i.name, i.name_en ?? "", i.name_pl ?? ""]),
|
||||
["code", "name", ...langCodes.map((c) => `name_${c}`)],
|
||||
...items.map((i) => [i.code, i.name, ...langCodes.map((c) => i.translations[c] ?? "")]),
|
||||
];
|
||||
return new Response(toCsv(rows), {
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user