Files
formbricks/apps/web/tolgee/language.ts
T
2025-04-21 15:57:54 +02:00

13 lines
516 B
TypeScript

import { DEFAULT_LOCALE } from "@/lib/constants";
import { getUserLocale } from "@/lib/user/service";
import { findMatchingLocale } from "@/lib/utils/locale";
import { authOptions } from "@/modules/auth/lib/authOptions";
import { getServerSession } from "next-auth";
export async function getLocale() {
const session = await getServerSession(authOptions);
let locale = session ? await getUserLocale(session.user?.id) : await findMatchingLocale();
locale = locale ? locale : DEFAULT_LOCALE;
return locale;
}