diff --git a/apps/web/app/_utils.tsx b/apps/web/app/_utils.tsx index da2b389593..a4bcdf1d10 100644 --- a/apps/web/app/_utils.tsx +++ b/apps/web/app/_utils.tsx @@ -1,12 +1,33 @@ import { type TFunction } from "i18next"; +import i18next from "i18next"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import { headers } from "next/headers"; import { constructGenericImage } from "@calcom/lib/OgImages"; import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; +//@ts-expect-error no type definitions +import config from "@calcom/web/next-i18next.config"; import { preparePageMetadata } from "@lib/metadata"; +const create = async (locale: string, ns: string) => { + const { _nextI18Next } = await serverSideTranslations(locale, [ns], config); + + const _i18n = i18next.createInstance(); + _i18n.init({ + lng: locale, + resources: _nextI18Next?.initialI18nStore, + fallbackLng: _nextI18Next?.userConfig?.i18n.defaultLocale, + }); + return _i18n; +}; + +const getFixedT = async (locale: string, ns: string) => { + const i18n = await create(locale, ns); + + return i18n.getFixedT(locale, ns); +}; + export const _generateMetadata = async ( getTitle: (t: TFunction) => string, getDescription: (t: TFunction) => string diff --git a/packages/lib/server/getFixedT.ts b/packages/lib/server/getFixedT.ts deleted file mode 100644 index 692c1c8dcc..0000000000 --- a/packages/lib/server/getFixedT.ts +++ /dev/null @@ -1,23 +0,0 @@ -import i18next from "i18next"; -import { serverSideTranslations } from "next-i18next/serverSideTranslations"; - -//@ts-expect-error no type definitions -import config from "@calcom/web/next-i18next.config"; - -export const create = async (locale: string, ns: string) => { - const { _nextI18Next } = await serverSideTranslations(locale, [ns], config); - - const _i18n = i18next.createInstance(); - _i18n.init({ - lng: locale, - resources: _nextI18Next?.initialI18nStore, - fallbackLng: _nextI18Next?.userConfig?.i18n.defaultLocale, - }); - return _i18n; -}; - -export const getFixedT = async (locale: string, ns: string) => { - const i18n = await create(locale, ns); - - return i18n.getFixedT(locale, ns); -};