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

@@ -43,10 +43,22 @@ async function restoreSongs() {
// Simple normalization
const normalizedGenre = genreName.trim();
// Upsert genre (we can't use upsert easily with connect, so find or create first)
let genre = await prisma.genre.findUnique({ where: { name: normalizedGenre } });
// Find genre by checking all genres (name is now JSON)
const allGenres = await prisma.genre.findMany();
let genre = allGenres.find(g => {
const name = g.name as any;
return (typeof name === 'string' && name === normalizedGenre) ||
(typeof name === 'object' && (name.de === normalizedGenre || name.en === normalizedGenre));
});
if (!genre) {
genre = await prisma.genre.create({ data: { name: normalizedGenre } });
// Create with JSON structure
genre = await prisma.genre.create({
data: {
name: { de: normalizedGenre, en: normalizedGenre },
active: true
}
});
console.log(`Created genre: ${normalizedGenre}`);
}
genreConnect.push({ id: genre.id });

View File

@@ -0,0 +1,31 @@
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
console.log('Verifying i18n migration...');
const genre = await prisma.genre.findFirst();
if (!genre) {
console.log('No genres found to verify.');
return;
}
console.log('First genre:', JSON.stringify(genre, null, 2));
if (typeof genre.name === 'object' && genre.name !== null && 'de' in (genre.name as any)) {
console.log('SUCCESS: Genre name is a JSON object with "de" key.');
} else {
console.error('FAILURE: Genre name is NOT in expected format:', genre.name);
process.exit(1);
}
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});