fix: try without loose locale pick

This commit is contained in:
zomars 2023-08-21 16:08:03 -07:00
parent 4bc6d53a89
commit 5ed649c131
3 changed files with 3 additions and 5 deletions

View File

@ -28,7 +28,7 @@ function useClientLocale(locales: string[]) {
if (typeof window !== "undefined") {
// This is the only way I found to ensure the prefetched locale is used on first render
// FIXME: Find a better way to pick the best matching locale from the browser
return parser.pick(locales, window.navigator.language, { loose: true }) || window.navigator.language;
return parser.pick(locales, window.navigator.language) || window.navigator.language;
}
// If the browser is not available, use English
return "en";

View File

@ -14,9 +14,7 @@ export async function getLocaleFromRequest(
if (session?.user?.locale) return session.user.locale;
let preferredLocale: string | null | undefined;
if (req.headers["accept-language"]) {
preferredLocale = parser.pick(i18n.locales, req.headers["accept-language"], {
loose: true,
}) as Maybe<string>;
preferredLocale = parser.pick(i18n.locales, req.headers["accept-language"]) as Maybe<string>;
}
return preferredLocale ?? i18n.defaultLocale;
}

View File

@ -8,7 +8,7 @@ export const i18nInputSchema = z.object({
locale: z
.string()
.min(2)
.transform((locale) => parser.pick<string>(i18n.locales, locale, { loose: true }) || locale),
.transform((locale) => parser.pick<string>(i18n.locales, locale) || locale),
CalComVersion: z.string(),
});