From 5ed649c13117fee8bc507098353de0f18e98d971 Mon Sep 17 00:00:00 2001 From: zomars Date: Mon, 21 Aug 2023 16:08:03 -0700 Subject: [PATCH] fix: try without loose locale pick --- apps/web/components/I18nLanguageHandler.tsx | 2 +- packages/lib/i18n.ts | 4 +--- packages/trpc/server/routers/publicViewer/i18n.schema.ts | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/web/components/I18nLanguageHandler.tsx b/apps/web/components/I18nLanguageHandler.tsx index 5c7fe018ee..f42256002e 100644 --- a/apps/web/components/I18nLanguageHandler.tsx +++ b/apps/web/components/I18nLanguageHandler.tsx @@ -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"; diff --git a/packages/lib/i18n.ts b/packages/lib/i18n.ts index 5d67b291e6..2e3d8a6aad 100644 --- a/packages/lib/i18n.ts +++ b/packages/lib/i18n.ts @@ -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; + preferredLocale = parser.pick(i18n.locales, req.headers["accept-language"]) as Maybe; } return preferredLocale ?? i18n.defaultLocale; } diff --git a/packages/trpc/server/routers/publicViewer/i18n.schema.ts b/packages/trpc/server/routers/publicViewer/i18n.schema.ts index 67feeb8816..95638b387e 100644 --- a/packages/trpc/server/routers/publicViewer/i18n.schema.ts +++ b/packages/trpc/server/routers/publicViewer/i18n.schema.ts @@ -8,7 +8,7 @@ export const i18nInputSchema = z.object({ locale: z .string() .min(2) - .transform((locale) => parser.pick(i18n.locales, locale, { loose: true }) || locale), + .transform((locale) => parser.pick(i18n.locales, locale) || locale), CalComVersion: z.string(), });