Implementiere i18n für Frontend, Admin und Datenbank

This commit is contained in:
Hördle Bot
2025-11-28 15:36:06 +01:00
parent 9df9a808bf
commit 771d0d06f3
37 changed files with 3717 additions and 560 deletions

View File

@@ -1,12 +1,26 @@
import { NextResponse } from 'next/server';
import { getOrCreateDailyPuzzle } from '@/lib/dailyPuzzle';
import { PrismaClient } from '@prisma/client';
import { getLocalizedValue } from '@/lib/i18n';
const prisma = new PrismaClient();
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const genreName = searchParams.get('genre');
const puzzle = await getOrCreateDailyPuzzle(genreName);
let genre = null;
if (genreName) {
// Find genre by localized name (try both locales)
const allGenres = await prisma.genre.findMany();
genre = allGenres.find(g =>
getLocalizedValue(g.name, 'de') === genreName ||
getLocalizedValue(g.name, 'en') === genreName
) || null;
}
const puzzle = await getOrCreateDailyPuzzle(genre);
if (!puzzle) {
return NextResponse.json({ error: 'Failed to get or create puzzle' }, { status: 404 });