109 lines
4.0 KiB
TypeScript
109 lines
4.0 KiB
TypeScript
/**
|
||
* The words of every email, in each language an instance can pick with
|
||
* `GERBEUR_EMAIL_LOCALE`. The templates beside this module read
|
||
* `STRINGS[EMAIL_LOCALE]`. French follows the interface's own words (a dump is
|
||
* a "reco", a playlist a "collection") and puts a no-break space before
|
||
* `: ! ?`.
|
||
*
|
||
* @module
|
||
*/
|
||
|
||
import type { EmailLocale } from "../config.ts";
|
||
|
||
/** A no-break space, which French typography puts before `: ! ?`. */
|
||
const NB = " ";
|
||
|
||
/**
|
||
* Read by the templates for one language. A function takes what varies, the
|
||
* site's name first; none escapes what it is given.
|
||
*/
|
||
export interface MailStrings {
|
||
/** The footer's link to the settings. */
|
||
settings: string;
|
||
welcome: {
|
||
subject: (site: string) => string;
|
||
preheader: string;
|
||
/** The Markdown body, unless `GERBEUR_WELCOME_EMAIL_BODY` replaces it. */
|
||
body: string;
|
||
button: (site: string) => string;
|
||
reason: (site: string) => string;
|
||
};
|
||
reset: {
|
||
subject: (site: string) => string;
|
||
preheader: (hours: number) => string;
|
||
title: string;
|
||
hi: (username: string) => string;
|
||
body: (site: string, hours: number) => string;
|
||
button: string;
|
||
fallback: string;
|
||
ignore: string;
|
||
reason: string;
|
||
};
|
||
}
|
||
|
||
/** Every email's words, by language. */
|
||
export const STRINGS: Record<EmailLocale, MailStrings> = {
|
||
en: {
|
||
settings: "Settings",
|
||
welcome: {
|
||
subject: (site) => `Welcome to ${site}`,
|
||
preheader: "Your account is ready.",
|
||
body:
|
||
"# Welcome to {{site_name}}!\n\nHi **{{username}}**,\n\nYour account has been created successfully. Welcome aboard!",
|
||
button: (site) => `Open ${site}`,
|
||
reason: (site) =>
|
||
`You're getting this email because an account was created on ${site} with this address.`,
|
||
},
|
||
reset: {
|
||
subject: (site) => `Reset your ${site} password`,
|
||
preheader: (hours) =>
|
||
`The link works once, for ${hours} ${hours === 1 ? "hour" : "hours"}.`,
|
||
title: "Reset your password",
|
||
hi: (username) => `Hi ${username},`,
|
||
body: (site, hours) =>
|
||
`Someone asked to reset the password of your ${site} account. The button below lets you choose a new one. It works once, for ${hours} ${
|
||
hours === 1 ? "hour" : "hours"
|
||
}.`,
|
||
button: "Reset password",
|
||
fallback:
|
||
"If the button doesn't work, paste this link into your browser:",
|
||
ignore:
|
||
"If you didn't ask for this, ignore this email. Your password stays the same.",
|
||
reason:
|
||
"You're getting this email because a password reset was requested for this address.",
|
||
},
|
||
},
|
||
fr: {
|
||
settings: "Paramètres",
|
||
welcome: {
|
||
subject: (site) => `Bienvenue sur ${site}`,
|
||
preheader: "Votre compte est prêt.",
|
||
body:
|
||
`# Bienvenue sur {{site_name}}${NB}!\n\nBonjour **{{username}}**,\n\nVotre compte a bien été créé. Bienvenue à bord${NB}!`,
|
||
button: (site) => `Ouvrir ${site}`,
|
||
reason: (site) =>
|
||
`Vous recevez cet e-mail car un compte ${site} a été créé avec cette adresse.`,
|
||
},
|
||
reset: {
|
||
subject: (site) => `Réinitialisez votre mot de passe ${site}`,
|
||
preheader: (hours) =>
|
||
`Le lien ne fonctionne qu'une fois, pendant ${hours}${NB}${
|
||
hours < 2 ? "heure" : "heures"
|
||
}.`,
|
||
title: "Réinitialiser votre mot de passe",
|
||
hi: (username) => `Bonjour ${username},`,
|
||
body: (site, hours) =>
|
||
`Quelqu'un a demandé à réinitialiser le mot de passe de votre compte ${site}. Le bouton ci-dessous vous permet d'en choisir un nouveau. Il ne fonctionne qu'une fois, pendant ${hours}${NB}${
|
||
hours < 2 ? "heure" : "heures"
|
||
}.`,
|
||
button: "Choisir un nouveau mot de passe",
|
||
fallback:
|
||
`Si le bouton ne fonctionne pas, collez ce lien dans votre navigateur${NB}:`,
|
||
ignore:
|
||
"Si vous n'êtes pas à l'origine de cette demande, ignorez cet e-mail. Votre mot de passe ne change pas.",
|
||
reason:
|
||
"Vous recevez cet e-mail car une réinitialisation de mot de passe a été demandée pour cette adresse.",
|
||
},
|
||
},
|
||
};
|