Pages

Emails

This app emails people in their own language: a booking's confirmation, a reminder the day before, a cancellation, and the private link to delete an event. Here are two of them, made by the app's own code for a sample event, in this page's language, and what it takes for each to arrive the right way round.

Two of the emails

A booking's confirmation

Your seat at أمسية خط عربي

The text version, sent with it
Hello Laila,

You have a seat at أمسية خط عربي. It starts Monday, March 8 at 7:00 PM GMT+2.

The event's page:

https://void-fbtee-example.gedw99.workers.dev/en-US/events/d57a8bf2-5909-4475-a407-12a879df5f01
The private link, to whoever posted the event

Your private link for أمسية خط عربي

The text version, sent with it
You posted أمسية خط عربي.

Keep this email: the link below is the only way to delete your event later. Anyone with it can delete the event, so don't share it.

https://void-fbtee-example.gedw99.workers.dev/en-US/events/d57a8bf2-5909-4475-a407-12a879df5f01#key=…

What a translated email needs

In the recipient's language

An email goes out from an action, a queue or a scheduled job, often caused by someone else: a cancellation reaches everyone booked, each in their own language. The language is saved with the booking, and void-fbtee's inLocale runs the email's code in it, its fbs strings and its dates included.

src/events/emails.ts
inLocale(booking.locale, ({ locale, dir }) => {

Language and direction on the content

Gmail drops the email's html, head and body elements and keeps what's inside, so an Arabic email that says right to left only on html shows left to right. The content's own box says it too.

src/events/EmailLayout.tsx
<Container lang={locale} dir={dir} …>

The email builder's own defaults

React Email, which this app builds its emails with, writes English, left to right around the content unless its Body is given the email's own language and direction.

src/events/EmailLayout.tsx
<Body lang={locale} dir={dir} …>

Text in another language

An event's title is as its organiser wrote it, so it can be in another language than the email, as the Arabic title in the English and Thai emails here. It's marked with its own language and direction, with void-fbtee's langAttrs, as on the site's pages.

src/events/emails.ts
title: { text: event.title, ...langAttrs(event.titleLocale) },
src/events/EmailLayout.tsx
<bdi lang={title.lang} dir={title.dir}>

A written-out address

A web address is read left to right in every language. Written out in a right-to-left email, as the private link is, its parts come out reversed unless it's marked left to right.

src/events/EmailLayout.tsx
<a href={link} dir="ltr" …>

Images inside the email

The logo is sent inside the email, with Void's inline attachments, rather than linked: it shows in every mail app, and in development too, where the site's address is localhost.

src/events/emails.ts
attachments: [logoAttachment],
src/events/EmailLayout.tsx
<Img src="cid:logo" width="24" height="24" alt="" />

A PDF attached

A booking's confirmation carries its ticket as a PDF, in the same language. The PDFs page shows how it's printed.

src/events/emails.ts
[{ filename: "ticket.pdf", content: booking.ticket, contentType: "application/pdf" }]

Used here, and explained on the Components page: langAttrs.