remove comments

This commit is contained in:
daniel31x13 2024-05-28 17:12:10 -04:00
parent f921ecaa96
commit adcc4e85ac

View File

@ -4,14 +4,10 @@ import { i18n } from "next-i18next.config";
import { getToken } from "next-auth/jwt";
import { prisma } from "../api/db";
// Keep this in a separate file, it's for logged out users
// For logged in users, we'll use their preferred language from the database (default: en)
const getServerSideProps: GetServerSideProps = async (ctx) => {
const acceptLanguageHeader = ctx.req.headers["accept-language"];
const availableLanguages = i18n.locales;
// Check if it's a logged in user
// If it is, get the user's preferred language from the database
const token = await getToken({ req: ctx.req });
if (token) {
@ -30,17 +26,14 @@ const getServerSideProps: GetServerSideProps = async (ctx) => {
}
}
// Parse the accept-language header to get an array of languages
const acceptedLanguages = acceptLanguageHeader
?.split(",")
.map((lang) => lang.split(";")[0]);
// Find the best match between the accepted languages and available languages
let bestMatch = acceptedLanguages?.find((lang) =>
availableLanguages.includes(lang)
);
// If no direct match, find the best partial match
if (!bestMatch) {
acceptedLanguages?.some((acceptedLang) => {
const partialMatch = availableLanguages.find((lang) =>