Implement i18n with German and English support (default DE)

This commit is contained in:
2026-01-12 21:38:05 +01:00
parent a60d456b3b
commit 62e1f5f1b4
14 changed files with 471 additions and 228 deletions

View File

@@ -4,8 +4,15 @@ import prisma from "@/lib/prisma"
import { revalidatePath } from "next/cache"
import { headers } from "next/headers"
import { sendNotification } from "@/lib/notifications"
import { getDictionary } from "@/get-dictionary"
export async function updatePlan(
planId: string,
data: { instructions?: string; webhookUrl?: string; notifyAll?: boolean },
lang: string = "en"
) {
const dict = await getDictionary(lang as any)
export async function updatePlan(planId: string, data: { instructions?: string; webhookUrl?: string; notifyAll?: boolean }) {
const plan = await prisma.plan.update({
where: { id: planId },
data: {
@@ -18,9 +25,13 @@ export async function updatePlan(planId: string, data: { instructions?: string;
if (data.instructions && plan.webhookUrl && plan.notifyAll) {
const host = (await headers()).get("host")
const protocol = host?.includes("localhost") ? "http" : "https"
const planUrl = `${protocol}://${host}/dashboard/${planId}`
await sendNotification(plan.webhookUrl, `📝 UPDATED: Cat instructions have been modified.\nPlan: ${planUrl}`)
const planUrl = `${protocol}://${host}/${lang}/dashboard/${planId}`
await sendNotification(
plan.webhookUrl,
dict.notifications.instructionsUpdated.replace("{url}", planUrl)
)
}
revalidatePath(`/dashboard/${planId}`)
revalidatePath(`/${lang}/dashboard/${planId}`)
}