feat(i18n): improve ai chat and settings localization
This commit is contained in:
@@ -9,7 +9,7 @@ export async function PATCH(request: Request, { params }: { params: Promise<{ cl
|
||||
const actor = await getSessionContextFromHeaders(new Headers(request.headers));
|
||||
|
||||
if (!actor) {
|
||||
return NextResponse.json({ error: "Oturum gerekli." }, { status: 401 });
|
||||
return NextResponse.json({ error: "clients.detail.portalLocaleUnauthenticated" }, { status: 401 });
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -18,14 +18,25 @@ export async function PATCH(request: Request, { params }: { params: Promise<{ cl
|
||||
return NextResponse.json(result);
|
||||
} catch (error) {
|
||||
if (error instanceof SyntaxError) {
|
||||
return NextResponse.json({ error: "Geçersiz JSON gövdesi." }, { status: 400 });
|
||||
return NextResponse.json({ error: "clients.detail.invalidRequest" }, { status: 400 });
|
||||
}
|
||||
if (error instanceof PortalInvitationError) {
|
||||
const status = error.code === "FORBIDDEN" ? 403 : error.code === "CLIENT_NOT_FOUND" ? 404 : 400;
|
||||
return NextResponse.json({ error: error.message, code: error.code }, { status });
|
||||
return NextResponse.json({ error: portalLocaleErrorKey(error.code), code: error.code }, { status });
|
||||
}
|
||||
|
||||
console.error("Client portal locale update failed", error);
|
||||
return NextResponse.json({ error: "Portal dili güncellenemedi." }, { status: 500 });
|
||||
return NextResponse.json({ error: "clients.detail.portalLocaleUpdateFailed" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
function portalLocaleErrorKey(code: PortalInvitationError["code"]) {
|
||||
switch (code) {
|
||||
case "FORBIDDEN":
|
||||
return "clients.detail.portalLocaleForbidden";
|
||||
case "CLIENT_NOT_FOUND":
|
||||
return "clients.detail.portalLocaleClientNotFound";
|
||||
default:
|
||||
return "clients.detail.portalLocaleUpdateFailed";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user