perf: Cache translations per language/per release (#10843)
Co-authored-by: zomars <[email protected]>
This commit is contained in:
1 parent
e8554ed5c5
commit
3f273235a6
18 files changed
+75
-80
No files matched your search
@@ -9,6 +9,10 @@ import { appRouter } from "@calcom/trpc/server/routers/_app";
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const { i18n } = require("@calcom/config/next-i18next.config");
|
||||
|
||||
// TODO: Consolidate this constant
|
||||
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||
const CalComVersion = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA || "NA";
|
||||
|
||||
/**
|
||||
* Initialize static site rendering tRPC helpers.
|
||||
* Provides a method to prefetch tRPC-queries in a `getStaticProps`-function.
|
||||
@@ -37,7 +41,7 @@ export async function ssgInit<TParams extends { locale?: string }>(opts: GetStat
|
||||
});
|
||||
|
||||
// always preload i18n
|
||||
await ssg.viewer.public.i18n.fetch();
|
||||
await ssg.viewer.public.i18n.fetch({ locale, CalComVersion });
|
||||
|
||||
return ssg;
|
||||
}
|
||||
@@ -7,6 +7,10 @@ import { createProxySSGHelpers } from "@calcom/trpc/react/ssg";
|
||||
import { createContext } from "@calcom/trpc/server/createContext";
|
||||
import { appRouter } from "@calcom/trpc/server/routers/_app";
|
||||
|
||||
// TODO: Consolidate this constant
|
||||
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||
const CalComVersion = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA || "NA";
|
||||
|
||||
/**
|
||||
* Initialize server-side rendering tRPC helpers.
|
||||
* Provides a method to prefetch tRPC-queries in a `getServerSideProps`-function.
|
||||
@@ -25,7 +29,7 @@ export async function ssrInit(context: GetServerSidePropsContext) {
|
||||
});
|
||||
|
||||
// always preload "viewer.public.i18n"
|
||||
await ssr.viewer.public.i18n.fetch();
|
||||
await ssr.viewer.public.i18n.fetch({ locale, CalComVersion });
|
||||
// So feature flags are available on first render
|
||||
await ssr.viewer.features.map.prefetch();
|
||||
// Provides a better UX to the users who have already upgraded.
|
||||
|
||||
Reference in new issue
Block a user