Implementiere i18n für Frontend, Admin und Datenbank
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user