From f4218c3115bf559436567827788391c33de0c82a Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Mon, 2 Sep 2024 19:30:58 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Translations=20for=20Email=20Notifi?= =?UTF-8?q?cations=20(#1278)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Niko Heller --- apps/web/declarations/i18next.d.ts | 3 + apps/web/package.json | 3 +- apps/web/src/components/featurebase.tsx | 100 --- apps/web/src/components/trans.tsx | 14 +- apps/web/src/pages/api/trpc/[trpc].ts | 6 +- apps/web/src/utils/auth.ts | 24 +- apps/web/src/utils/emails.ts | 46 +- apps/web/tsconfig.json | 2 +- crowdin.yml | 2 + package.json | 2 +- packages/backend/trpc/context.ts | 3 +- packages/backend/trpc/routers/auth.ts | 3 +- packages/backend/trpc/routers/polls.ts | 120 ++-- .../backend/trpc/routers/polls/comments.ts | 13 +- .../trpc/routers/polls/participants.ts | 41 +- packages/backend/tsconfig.json | 2 +- .../migration.sql | 2 + packages/database/prisma/schema.prisma | 1 + packages/emails/i18next-scanner.config.js | 29 + packages/emails/i18next.d.ts | 15 + packages/emails/locales/en/emails.json | 49 ++ packages/emails/package.json | 14 +- .../emails/src/components/email-context.tsx | 16 + .../email-layout.tsx | 22 +- .../notification-email.tsx | 32 +- .../styled-components.tsx | 2 +- packages/emails/src/i18n.ts | 26 + .../emails/src/previews/finalized-host.tsx | 19 + .../src/previews/finalized-participant.tsx | 17 + packages/emails/src/previews/login.tsx | 12 + packages/emails/src/previews/new-comment.tsx | 16 + .../previews/new-participant-confirmation.tsx | 12 + .../emails/src/previews/new-participant.tsx | 14 + packages/emails/src/previews/new-poll.tsx | 14 + packages/emails/src/previews/register.tsx | 6 + .../{templates => previews}/static/logo.png | Bin packages/emails/src/send-email.tsx | 61 +- .../templates/_components/email-context.tsx | 13 - .../emails/src/templates/finalized-host.tsx | 78 +- .../src/templates/finalized-participant.tsx | 76 +- packages/emails/src/templates/login.tsx | 71 +- packages/emails/src/templates/new-comment.tsx | 64 +- .../new-participant-confirmation.tsx | 83 ++- .../emails/src/templates/new-participant.tsx | 71 +- packages/emails/src/templates/new-poll.tsx | 58 +- packages/emails/src/templates/register.tsx | 60 +- packages/emails/src/types.ts | 12 + packages/emails/tsconfig.json | 10 +- packages/ui/src/index.ts | 2 +- turbo.json | 3 +- yarn.lock | 677 ++++-------------- 51 files changed, 1071 insertions(+), 970 deletions(-) delete mode 100644 apps/web/src/components/featurebase.tsx create mode 100644 packages/database/prisma/migrations/20240901171230_participant_locale/migration.sql create mode 100644 packages/emails/i18next-scanner.config.js create mode 100644 packages/emails/i18next.d.ts create mode 100644 packages/emails/locales/en/emails.json create mode 100644 packages/emails/src/components/email-context.tsx rename packages/emails/src/{templates/_components => components}/email-layout.tsx (63%) rename packages/emails/src/{templates/_components => components}/notification-email.tsx (52%) rename packages/emails/src/{templates/_components => components}/styled-components.tsx (98%) create mode 100644 packages/emails/src/i18n.ts create mode 100644 packages/emails/src/previews/finalized-host.tsx create mode 100644 packages/emails/src/previews/finalized-participant.tsx create mode 100644 packages/emails/src/previews/login.tsx create mode 100644 packages/emails/src/previews/new-comment.tsx create mode 100644 packages/emails/src/previews/new-participant-confirmation.tsx create mode 100644 packages/emails/src/previews/new-participant.tsx create mode 100644 packages/emails/src/previews/new-poll.tsx create mode 100644 packages/emails/src/previews/register.tsx rename packages/emails/src/{templates => previews}/static/logo.png (100%) delete mode 100644 packages/emails/src/templates/_components/email-context.tsx create mode 100644 packages/emails/src/types.ts diff --git a/apps/web/declarations/i18next.d.ts b/apps/web/declarations/i18next.d.ts index 9ded39e18..8c9bf6f51 100644 --- a/apps/web/declarations/i18next.d.ts +++ b/apps/web/declarations/i18next.d.ts @@ -1,9 +1,12 @@ import "i18next"; +import emails from "@rallly/emails/locales/emails.json"; + import app from "../public/locales/en/app.json"; interface I18nNamespaces { app: typeof app; + emails: typeof emails; } declare module "i18next" { diff --git a/apps/web/package.json b/apps/web/package.json index 9abb8152e..f7573363b 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -31,7 +31,8 @@ "@rallly/languages": "*", "@rallly/tailwind-config": "*", "@rallly/ui": "*", - "@sentry/nextjs": "^8", + "@rallly/emails": "*", + "@sentry/nextjs": "*", "@svgr/webpack": "^6.5.1", "@t3-oss/env-nextjs": "^0.11.0", "@tanstack/react-query": "^4.0.0", diff --git a/apps/web/src/components/featurebase.tsx b/apps/web/src/components/featurebase.tsx deleted file mode 100644 index 48ae3b2d6..000000000 --- a/apps/web/src/components/featurebase.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import { cn } from "@rallly/ui"; -import { Button } from "@rallly/ui/button"; -import { Tooltip, TooltipContent, TooltipTrigger } from "@rallly/ui/tooltip"; -import { HelpCircleIcon } from "lucide-react"; -import Script from "next/script"; -import React from "react"; - -import { Trans } from "@/components/trans"; -import { useUser } from "@/components/user-provider"; -import { isFeedbackEnabled } from "@/utils/constants"; - -const FeaturebaseScript = () => ( -