From 2146c0444421cb8b07061ba8b5a4235003ef1fbd Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Wed, 2 Oct 2024 19:32:33 -0400 Subject: [PATCH] fix: i18n for app router (#16909) * fix: translations for app router * fix build error --- apps/web/lib/app-providers-app-dir.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/web/lib/app-providers-app-dir.tsx b/apps/web/lib/app-providers-app-dir.tsx index cd7ce9eb08..463db38a70 100644 --- a/apps/web/lib/app-providers-app-dir.tsx +++ b/apps/web/lib/app-providers-app-dir.tsx @@ -71,10 +71,12 @@ const CustomI18nextProvider = (props: { children: React.ReactElement; i18n?: SSR **/ const session = useSession(); - const locale = - session?.data?.user.locale ?? typeof window !== "undefined" - ? window.document.documentElement.lang || "en" + const fallbackLocale = + typeof window !== "undefined" && window.document.documentElement.lang + ? window.document.documentElement.lang : "en"; + const newLocale = typeof window !== "undefined" && window.calNewLocale ? window.calNewLocale : null; + const locale = session?.data?.user.locale ?? newLocale ?? fallbackLocale; useEffect(() => { try {