Files
formbricks/apps/web/i18n/request.ts
Dhruwang Jariwala b3e6e8d5d0 feat: multi language UI (#3133)
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
2024-10-31 08:23:57 +00:00

21 lines
764 B
TypeScript

import { getServerSession } from "next-auth";
import { getRequestConfig } from "next-intl/server";
import { authOptions } from "@formbricks/lib/authOptions";
import { DEFAULT_LOCALE } from "@formbricks/lib/constants";
import { getUserLocale } from "@formbricks/lib/user/service";
import { findMatchingLocale } from "@formbricks/lib/utils/locale";
export default getRequestConfig(async () => {
const session = await getServerSession(authOptions);
const locale = session ? await getUserLocale(session.user?.id) : findMatchingLocale();
// Lazy load the locale-specific messages
const messages = await import(`@formbricks/lib/messages/${locale ?? DEFAULT_LOCALE}.json`).then(
(module) => module.default
);
return {
locale,
messages,
};
});