From dc803a217821c5a7a4c01c0608c40423e336b2f2 Mon Sep 17 00:00:00 2001 From: Dmytro Hryshyn Date: Thu, 26 Oct 2023 11:43:48 +0300 Subject: [PATCH] revert server-side-translations hack --- apps/web/app/_not-found.tsx | 2 +- apps/web/pages/auth/forgot-password/[id].tsx | 2 +- apps/web/pages/auth/forgot-password/index.tsx | 2 +- apps/web/pages/getting-started/[[...step]].tsx | 2 +- apps/web/server/lib/serverSideTranslations.ts | 8 -------- apps/web/server/lib/ssg.ts | 2 +- apps/web/server/lib/ssr.ts | 2 +- packages/lib/server/i18n.ts | 3 +-- packages/trpc/server/routers/publicViewer/i18n.handler.ts | 2 +- 9 files changed, 8 insertions(+), 17 deletions(-) delete mode 100644 apps/web/server/lib/serverSideTranslations.ts diff --git a/apps/web/app/_not-found.tsx b/apps/web/app/_not-found.tsx index 68a3d2c13d..8b18b29c5d 100644 --- a/apps/web/app/_not-found.tsx +++ b/apps/web/app/_not-found.tsx @@ -1,8 +1,8 @@ import NotFoundPage from "@pages/404"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import { cookies, headers } from "next/headers"; import { getLocale } from "@calcom/features/auth/lib/getLocale"; -import { serverSideTranslations } from "@calcom/web/server/lib/serverSideTranslations"; import PageWrapper from "@components/PageWrapperAppDir"; diff --git a/apps/web/pages/auth/forgot-password/[id].tsx b/apps/web/pages/auth/forgot-password/[id].tsx index 117dfc1a6e..4bbb7e6a8c 100644 --- a/apps/web/pages/auth/forgot-password/[id].tsx +++ b/apps/web/pages/auth/forgot-password/[id].tsx @@ -1,5 +1,6 @@ import type { GetServerSidePropsContext } from "next"; import { getCsrfToken } from "next-auth/react"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import Link from "next/link"; import type { CSSProperties } from "react"; import { useForm } from "react-hook-form"; @@ -8,7 +9,6 @@ import { getLocale } from "@calcom/features/auth/lib/getLocale"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import prisma from "@calcom/prisma"; import { Button, PasswordField, Form } from "@calcom/ui"; -import { serverSideTranslations } from "@calcom/web/server/lib/serverSideTranslations"; import PageWrapper from "@components/PageWrapper"; import AuthContainer from "@components/ui/AuthContainer"; diff --git a/apps/web/pages/auth/forgot-password/index.tsx b/apps/web/pages/auth/forgot-password/index.tsx index 4d0e3443ec..fe68bc4e99 100644 --- a/apps/web/pages/auth/forgot-password/index.tsx +++ b/apps/web/pages/auth/forgot-password/index.tsx @@ -2,6 +2,7 @@ import { debounce } from "lodash"; import type { GetServerSidePropsContext } from "next"; import { getCsrfToken } from "next-auth/react"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import Link from "next/link"; import type { CSSProperties, SyntheticEvent } from "react"; import React from "react"; @@ -10,7 +11,6 @@ import { getLocale } from "@calcom/features/auth/lib/getLocale"; import { getServerSession } from "@calcom/features/auth/lib/getServerSession"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { Button, EmailField } from "@calcom/ui"; -import { serverSideTranslations } from "@calcom/web/server/lib/serverSideTranslations"; import PageWrapper from "@components/PageWrapper"; import AuthContainer from "@components/ui/AuthContainer"; diff --git a/apps/web/pages/getting-started/[[...step]].tsx b/apps/web/pages/getting-started/[[...step]].tsx index 4779a4fe24..c973b25754 100644 --- a/apps/web/pages/getting-started/[[...step]].tsx +++ b/apps/web/pages/getting-started/[[...step]].tsx @@ -1,4 +1,5 @@ import type { GetServerSidePropsContext } from "next"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import Head from "next/head"; import { usePathname, useRouter } from "next/navigation"; import type { CSSProperties } from "react"; @@ -14,7 +15,6 @@ import prisma from "@calcom/prisma"; import { trpc } from "@calcom/trpc"; import { Button, StepCard, Steps } from "@calcom/ui"; import { Loader } from "@calcom/ui/components/icon"; -import { serverSideTranslations } from "@calcom/web/server/lib/serverSideTranslations"; import PageWrapper from "@components/PageWrapper"; import { ConnectedCalendars } from "@components/getting-started/steps-views/ConnectCalendars"; diff --git a/apps/web/server/lib/serverSideTranslations.ts b/apps/web/server/lib/serverSideTranslations.ts deleted file mode 100644 index c20665df5d..0000000000 --- a/apps/web/server/lib/serverSideTranslations.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { serverSideTranslations as _serverSideTranslations } from "next-i18next/serverSideTranslations"; - -//@ts-expect-error no type definitions -import config from "@calcom/web/next-i18next.config"; - -export const serverSideTranslations: typeof _serverSideTranslations = async (locale, namespaces) => { - return _serverSideTranslations(locale, namespaces, config); -}; diff --git a/apps/web/server/lib/ssg.ts b/apps/web/server/lib/ssg.ts index f9312ea651..469653da97 100644 --- a/apps/web/server/lib/ssg.ts +++ b/apps/web/server/lib/ssg.ts @@ -1,11 +1,11 @@ import type { GetStaticPropsContext } from "next"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import superjson from "superjson"; import { CALCOM_VERSION } from "@calcom/lib/constants"; import prisma from "@calcom/prisma"; import { createProxySSGHelpers } from "@calcom/trpc/react/ssg"; import { appRouter } from "@calcom/trpc/server/routers/_app"; -import { serverSideTranslations } from "@calcom/web/server/lib/serverSideTranslations"; // eslint-disable-next-line @typescript-eslint/no-var-requires const { i18n } = require("@calcom/config/next-i18next.config"); diff --git a/apps/web/server/lib/ssr.ts b/apps/web/server/lib/ssr.ts index bd43c5e576..08922d5fe5 100644 --- a/apps/web/server/lib/ssr.ts +++ b/apps/web/server/lib/ssr.ts @@ -1,4 +1,5 @@ import type { GetServerSidePropsContext } from "next"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import superjson from "superjson"; import { getLocale } from "@calcom/features/auth/lib/getLocale"; @@ -6,7 +7,6 @@ import { CALCOM_VERSION } from "@calcom/lib/constants"; import { createProxySSGHelpers } from "@calcom/trpc/react/ssg"; import { createContext } from "@calcom/trpc/server/createContext"; import { appRouter } from "@calcom/trpc/server/routers/_app"; -import { serverSideTranslations } from "@calcom/web/server/lib/serverSideTranslations"; /** * Initialize server-side rendering tRPC helpers. diff --git a/packages/lib/server/i18n.ts b/packages/lib/server/i18n.ts index 300f84274a..b49658d07e 100644 --- a/packages/lib/server/i18n.ts +++ b/packages/lib/server/i18n.ts @@ -1,7 +1,6 @@ import i18next from "i18next"; import { i18n as nexti18next } from "next-i18next"; - -import { serverSideTranslations } from "../../../apps/web/server/lib/serverSideTranslations"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; export const getTranslation = async (locale: string, ns: string) => { const create = async () => { diff --git a/packages/trpc/server/routers/publicViewer/i18n.handler.ts b/packages/trpc/server/routers/publicViewer/i18n.handler.ts index 3156291efc..e21acb5f22 100644 --- a/packages/trpc/server/routers/publicViewer/i18n.handler.ts +++ b/packages/trpc/server/routers/publicViewer/i18n.handler.ts @@ -6,7 +6,7 @@ type I18nOptions = { export const i18nHandler = async ({ input }: I18nOptions) => { const { locale } = input; - const { serverSideTranslations } = await import("@calcom/web/server/lib/serverSideTranslations"); + const { serverSideTranslations } = await import("next-i18next/serverSideTranslations"); const i18n = await serverSideTranslations(locale, ["common", "vital"]); return {