Skip to content

Scheduling infrastructure for absolutely everyone.

hotfix: use session locale when dealing with SSG-ed pages (#11831)

Greg Pabiand72a1ee3285f
diff --git a/apps/web/lib/app-providers.tsx b/apps/web/lib/app-providers.tsx
index bc2d3aed784..50bde134633 100644
--- a/apps/web/lib/app-providers.tsx
+++ b/apps/web/lib/app-providers.tsx
@@ -71,7 +71,11 @@ const CustomI18nextProvider = (props: AppPropsWithoutNonce) => {
/**
* i18n should never be clubbed with other queries, so that it's caching can be managed independently.
**/
- const clientViewerI18n = useViewerI18n(props.pageProps.newLocale);
+
+ const session = useSession();
+ const locale = session?.data?.user.locale ?? props.pageProps.newLocale;
+
+ const clientViewerI18n = useViewerI18n(locale);
const i18n = clientViewerI18n.data?.i18n;
const passedProps = {
@@ -247,8 +251,8 @@ const AppProviders = (props: AppPropsWithChildren) => {
const RemainingProviders = (
<EventCollectionProvider options={{ apiPath: "/api/collect-events" }}>
- <CustomI18nextProvider {...propsWithoutNonce}>
- <SessionProvider session={pageProps.session ?? undefined}>
+ <SessionProvider session={pageProps.session ?? undefined}>
+ <CustomI18nextProvider {...propsWithoutNonce}>
<TooltipProvider>
{/* color-scheme makes background:transparent not work which is required by embed. We need to ensure next-theme adds color-scheme to `body` instead of `html`(https://github.com/pacocoursey/next-themes/blob/main/src/index.tsx#L74). Once that's done we can enable color-scheme support */}
<CalcomThemeProvider
@@ -264,8 +268,8 @@ const AppProviders = (props: AppPropsWithChildren) => {
</FeatureFlagsProvider>
</CalcomThemeProvider>
</TooltipProvider>
- </SessionProvider>
- </CustomI18nextProvider>
+ </CustomI18nextProvider>
+ </SessionProvider>
</EventCollectionProvider>
);