fix: try without loose locale pick
parent
4bc6d53a89
commit
5ed649c131
|
@ -28,7 +28,7 @@ function useClientLocale(locales: string[]) {
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
// This is the only way I found to ensure the prefetched locale is used on first render
|
// 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
|
// 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
|
// If the browser is not available, use English
|
||||||
return "en";
|
return "en";
|
||||||
|
|
|
@ -14,9 +14,7 @@ export async function getLocaleFromRequest(
|
||||||
if (session?.user?.locale) return session.user.locale;
|
if (session?.user?.locale) return session.user.locale;
|
||||||
let preferredLocale: string | null | undefined;
|
let preferredLocale: string | null | undefined;
|
||||||
if (req.headers["accept-language"]) {
|
if (req.headers["accept-language"]) {
|
||||||
preferredLocale = parser.pick(i18n.locales, req.headers["accept-language"], {
|
preferredLocale = parser.pick(i18n.locales, req.headers["accept-language"]) as Maybe<string>;
|
||||||
loose: true,
|
|
||||||
}) as Maybe<string>;
|
|
||||||
}
|
}
|
||||||
return preferredLocale ?? i18n.defaultLocale;
|
return preferredLocale ?? i18n.defaultLocale;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ export const i18nInputSchema = z.object({
|
||||||
locale: z
|
locale: z
|
||||||
.string()
|
.string()
|
||||||
.min(2)
|
.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(),
|
CalComVersion: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue