Basis: Certvia dev@a48c5fb als Fundament für Craftvia
Unveränderter Stand von certvia/dev (a48c5fb) plus Craftvia-Spezifikation und Brandbook unter docs/craftvia/. ISMS-Module werden im Folgecommit entfernt. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { getRequestConfig } from "next-intl/server";
|
||||
import { auth } from "@/server/auth";
|
||||
import { prisma } from "@/server/db";
|
||||
|
||||
/**
|
||||
* i18n (SPEC §7): alle UI-Strings kommen aus dem Message-Katalog.
|
||||
*
|
||||
* Die UI-Sprache ist eine PERSÖNLICHE Präferenz und lebt an der globalen
|
||||
* `Identity` (Option C, `uiLocale`) — sie folgt der Person über alle Mandanten.
|
||||
* Getrennt von `TenantSettings.locale` (= Vorlagen-Import-Sprache des Inhalts).
|
||||
*
|
||||
* Robust: auf Login-/Session-losen Seiten (oder wenn die Session keinen
|
||||
* Identity-Kontext trägt, z. B. reine Plattform-Sessions) fällt die Sprache auf
|
||||
* `de` zurück. Fehler bei der Auflösung dürfen das Rendering nie brechen.
|
||||
*/
|
||||
const SUPPORTED = new Set(["de", "en"]);
|
||||
|
||||
export default getRequestConfig(async () => {
|
||||
let locale = "de";
|
||||
try {
|
||||
const session = await auth();
|
||||
const identityId = session?.user?.identityId;
|
||||
if (identityId) {
|
||||
const identity = await prisma.identity.findUnique({
|
||||
where: { id: identityId },
|
||||
select: { uiLocale: true },
|
||||
});
|
||||
if (identity?.uiLocale && SUPPORTED.has(identity.uiLocale)) locale = identity.uiLocale;
|
||||
}
|
||||
} catch {
|
||||
locale = "de";
|
||||
}
|
||||
return {
|
||||
locale,
|
||||
messages: (await import(`../../messages/${locale}.json`)).default,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user