Skip to content

Commit 46b386f

Browse files
committed
move directory i18n directory up, use welcome email, translate subject
1 parent 6388374 commit 46b386f

File tree

14 files changed

+94
-108
lines changed

14 files changed

+94
-108
lines changed

actions/send-email.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
'use server';
22

33
import { Resend } from 'resend';
4-
import Pricing from '@/emails/pricing';
5-
import type { Locale } from '@/lib/i18n/i18n';
4+
import WelcomeEmail from '@/emails/welcome';
5+
import type { Locale } from '@/i18n/i18n';
6+
import { getT } from '@/i18n/get-t';
67

78
export async function sendEmail(locale: Locale) {
89
const resend = new Resend(process.env.RESEND_API_KEY);
910

11+
const { t } = await getT('welcome', locale);
12+
1013
const response = await resend.emails.send({
1114
from: 'Acme <onboarding@resend.dev>',
1215
to: ['delivered@resend.dev'],
13-
subject: 'Pricing discount',
14-
react: <Pricing locale={locale} />,
16+
subject: t('header'),
17+
react: <WelcomeEmail name="John Lennon" locale={locale} />,
1518
});
1619

1720
if (response.error) {

app/[locale]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { notFound } from 'next/navigation';
22
import { sendEmail } from '@/actions/send-email';
3-
import { type Locale, validLocales } from '@/lib/i18n/i18n';
4-
import { getT } from '@/lib/i18n/get-t';
3+
import { type Locale, validLocales } from '@/i18n/i18n';
4+
import { getT } from '@/i18n/get-t';
55

66
export function generateStaticParams() {
77
return validLocales.map((locale) => ({ locale }));

emails/pricing.tsx

Lines changed: 0 additions & 77 deletions
This file was deleted.

emails/welcome.tsx

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import {
2+
Body,
3+
Button,
4+
Container,
5+
Head,
6+
Heading,
7+
Hr,
8+
Html,
9+
Preview,
10+
Section,
11+
Tailwind,
12+
Text,
13+
} from '@react-email/components';
14+
import { getT } from '@/i18n/get-t';
15+
import type { Locale } from '@/i18n/i18n';
16+
17+
interface WelcomeProps {
18+
locale: Locale;
19+
name: string;
20+
}
21+
22+
export default async function WelcomeEmail({ locale, name }: WelcomeProps) {
23+
const { t } = await getT('welcome-email', locale);
24+
25+
return (
26+
<Html>
27+
<Head />
28+
<Preview>{t('header')}</Preview>
29+
<Tailwind>
30+
<Body className="bg-gray-100 font-sans">
31+
<Container className="mx-auto py-10 px-5">
32+
<Section className="bg-white rounded-lg p-8">
33+
<Heading className="text-2xl font-bold text-gray-900 m-0 mb-6">
34+
{t('header')}
35+
</Heading>
36+
<Text className="text-base leading-6 text-gray-600 m-0 mb-4">
37+
{t('hi')} {name}
38+
</Text>
39+
<Text className="text-base leading-6 text-gray-600 m-0 mb-4">
40+
{t('thanks')}
41+
</Text>
42+
<Button
43+
href="https://example.com/dashboard"
44+
className="bg-indigo-600 rounded-md text-white text-base font-semibold no-underline text-center block py-3 px-6 my-6"
45+
>
46+
{t('get-started')}
47+
</Button>
48+
<Hr className="border-gray-200 my-6" />
49+
<Text className="text-sm text-gray-400 m-0">
50+
{t('questions')}
51+
</Text>
52+
</Section>
53+
</Container>
54+
</Body>
55+
</Tailwind>
56+
</Html>
57+
);
58+
}
59+
60+
WelcomeEmail.PreviewProps = {
61+
locale: 'en',
62+
name: 'John Lennon',
63+
};
File renamed without changes.
File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"header": "Welcome to Acme",
3+
"hi": "Hi",
4+
"thanks": "Thanks for signing up! We're excited to have you on board.",
5+
"get-started": "Get Started",
6+
"questions": "If you have any questions, reply to this email. We're here to help!"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"header": "Bienvenido a Acme",
3+
"hi": "Hola",
4+
"thanks": "Gracias por registrarte! Estamos emocionados de tenerte en la plataforma.",
5+
"get-started": "Comenzar",
6+
"questions": "Si tienes alguna pregunta, responde a este correo electrónico. Estamos aquí para ayudarte!"
7+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"email.preview": "Oferta Exclusiva Só Para Você: Desbloqueie Funcionalidades com $12/mês",
2+
"""email.preview": "Oferta Exclusiva Só Para Você: Desbloqueie Funcionalidades com $12/mês",
33
"email.exclusive-offer": "Oferta Exclusiva",
44
"email.per-month": "/ mês",
55
"email.copy": "Criamos o plano perfeito especialmente adaptado às suas necessidades. Desbloqueie recursos premium com um valor imbatível.",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"header": "Bem-vindo à Acme",
3+
"hi": "Olá",
4+
"thanks": "Obrigado por se inscrever! Estamos animados em tê-lo conosco.",
5+
"get-started": "Começar",
6+
"questions": "Se você tiver alguma dúvida, responda a este e-mail. Estamos aqui para ajudar!"
7+
}

0 commit comments

Comments
 (0)