Skip to content

Commit

Permalink
imp: Homogeneize and improve the look of the emails
Browse files Browse the repository at this point in the history
  • Loading branch information
marienfressinaud committed Dec 4, 2024
1 parent dc89cf6 commit 7c9447d
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 113 deletions.
Binary file modified locales/fr_FR/LC_MESSAGES/main.mo
Binary file not shown.
95 changes: 41 additions & 54 deletions locales/fr_FR/LC_MESSAGES/main.po
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: Flus\n"
"POT-Creation-Date: 2024-12-01 15:50+0100\n"
"PO-Revision-Date: 2024-12-01 15:50+0100\n"
"POT-Creation-Date: 2024-12-04 21:46+0100\n"
"PO-Revision-Date: 2024-12-04 21:46+0100\n"
"Last-Translator: Marien Fressinaud <dev@marienfressinaud.fr>\n"
"Language-Team: \n"
"Language: fr_FR\n"
Expand Down Expand Up @@ -270,22 +270,22 @@ msgstr "Tous vos favoris importés depuis Pocket."
msgid "[%s] Contact: %s"
msgstr "[%s] Contact : %s"

#: mailers/Support.php:57
#: mailers/Support.php:61
#, php-format
msgid "[%s] Your message has been sent"
msgstr "[%s] Votre message a été envoyé"

#: mailers/Users.php:33
#: mailers/Users.php:44
#, php-format
msgid "[%s] Confirm your account"
msgstr "[%s] Confirmer votre compte"

#: mailers/Users.php:64
#: mailers/Users.php:77
#, php-format
msgid "[%s] Reset your password"
msgstr "[%s] Réinitialisation de votre mot de passe"

#: mailers/Users.php:102
#: mailers/Users.php:116
#, php-format
msgid "[%s] Your account will be deleted soon due to inactivity"
msgstr "[%s] Votre compte sera bientôt supprimé pour cause d'inactivité"
Expand Down Expand Up @@ -460,6 +460,11 @@ msgstr "plateforme inconnue"
msgid "%s on %s"
msgstr "%s sur %s"

#: utils/additionnal_translations.php:10
#, php-format
msgid "This email has been sent by %s (%s)"
msgstr "Ce courriel a été envoyé par %s (%s)"

#: utils/view_helpers.php:101
msgid "< 1 min"
msgstr "< 1 min"
Expand Down Expand Up @@ -634,6 +639,27 @@ msgstr "Rechercher des liens par mots ou URL"
msgid "Search"
msgstr "Rechercher"

#: views/_layouts/emails/default.phtml:15
#, php-format
msgid "Hello %s,"
msgstr "Bonjour %s,"

#: views/_layouts/emails/default.phtml:21
msgid "Best regards,"
msgstr "Bien à vous,"

#: views/_layouts/emails/default.phtml:25
#, php-format
msgid "The %s robot"
msgstr "Le robot %s"

#: views/_layouts/emails/default.phtml:30
#, php-format
msgid ""
"This email has been sent by <a href=\"%s\" style=\"color: #4f4e5e;\">%s</a>."
msgstr ""
"Ce courriel a été envoyé par <a href=\"%s\" style=\"color: #4f4e5e;\">%s</a>."

#: views/_layouts/error.phtml:22
msgid "Oh no&nbsp;😟"
msgstr "Oh non&nbsp;😟"
Expand Down Expand Up @@ -1703,11 +1729,7 @@ msgstr "Ce lien étant masqué, les commentaires sont privés."
msgid "New message from the support."
msgstr "Nouveau message depuis le support."

#: views/mailers/support/notification.phtml:2
msgid "Hello,"
msgstr "Bonjour,"

#: views/mailers/support/notification.phtml:6
#: views/mailers/support/notification.phtml:7
#, php-format
msgid ""
"Your message named “%s” has been sent. Someone will reply to you as soon as "
Expand All @@ -1716,17 +1738,7 @@ msgstr ""
"Votre message intitulé « %s » a été envoyé. Quelqu’un va vous répondre aussi "
"rapidement que possible !"

#: views/mailers/support/notification.phtml:10
#, php-format
msgid "Transactionally yours, the %s bot"
msgstr "Transactionnellement vôtre, le robot %s"

#: views/mailers/users/account_validation_email.phtml:2
#, php-format
msgid "Welcome %s,"
msgstr "Bienvenue %s,"

#: views/mailers/users/account_validation_email.phtml:6
#: views/mailers/users/account_validation_email.phtml:7
#, php-format
msgid ""
"Thank you for your inscription on %s. To finish, you’ll have to confirm your "
Expand All @@ -1737,17 +1749,7 @@ msgstr ""
"votre adresse courriel. Vous avez seulement à cliquer sur le lien suivant, "
"et tout devrait être bon ensuite :"

#: views/mailers/users/account_validation_email.phtml:13
#: views/mailers/users/reset_password_email.phtml:13
msgid "Have a nice day!"
msgstr "Bonne journée !"

#: views/mailers/users/inactivity_email.phtml:2
#, php-format
msgid "Hello %s,"
msgstr "Bonjour %s,"

#: views/mailers/users/inactivity_email.phtml:6
#: views/mailers/users/inactivity_email.phtml:7
#, php-format
msgid ""
"You receive this email because you haven’t been active on %s for several "
Expand All @@ -1762,29 +1764,15 @@ msgstr ""
"n’avez rien faire. Toutefois, si vous souhaitez conserver votre compte, vous "
"devez vous connecter à %s en cliquant sur le lien suivant :"

#: views/mailers/users/inactivity_email.phtml:13
#: views/mailers/users/inactivity_email.phtml:14
msgid ""
"Note that you will not receive any further notification that your account "
"will be deleted."
msgstr ""
"Notez que vous ne recevrez pas d’autre notification concernant la "
"suppression de votre compte."

#: views/mailers/users/inactivity_email.phtml:17
msgid "Best regards,"
msgstr "Bien à vous,"

#: views/mailers/users/inactivity_email.phtml:21
#, php-format
msgid "The %s robot"
msgstr "Le robot %s"

#: views/mailers/users/reset_password_email.phtml:2
#, php-format
msgid "Hi %s,"
msgstr "Bonjour %s,"

#: views/mailers/users/reset_password_email.phtml:6
#: views/mailers/users/reset_password_email.phtml:7
#, php-format
msgid ""
"You receive this email because you’ve asked to reset your password on %s. "
Expand All @@ -1794,12 +1782,11 @@ msgstr ""
"mot de passe sur %s. Vous avez seulement à cliquer sur le lien suivant et "
"suivre les instructions :"

#: views/mailers/users/reset_password_email.phtml:17
msgid ""
"P.S. – If you didn’t ask to reset your password, please ignore this email."
#: views/mailers/users/reset_password_email.phtml:14
msgid "If you didn’t ask to reset your password, please ignore this email."
msgstr ""
"P.S. – Si vous n’avez pas demandé à réinitialiser votre mot de passe, vous "
"pouvez ignorer ce courriel."
"Si vous n’avez pas demandé à réinitialiser votre mot de passe, vous pouvez "
"ignorer ce courriel."

#: views/mastodon/authorization.phtml:3 views/mastodon/authorization.phtml:11
msgid "Mastodon authorization"
Expand Down
7 changes: 6 additions & 1 deletion src/mailers/Support.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,19 @@ public function sendNotification(string $user_id, string $subject): bool

utils\Locale::setCurrentLocale($user->locale);

$logo_path = \App\Configuration::$app_path . '/public/static/logo.svg';
$logo_cid = md5($logo_path);
$this->mailer->addEmbeddedImage($logo_path, $logo_cid);

$brand = \App\Configuration::$application['brand'];
$current_subject = sprintf(_('[%s] Your message has been sent'), $brand);
$this->setBody(
'mailers/support/notification.phtml',
'mailers/support/notification.txt',
[
'logo_cid' => $logo_cid,
'username' => $user->username,
'subject' => $subject,
'brand' => $brand,
]
);

Expand Down
19 changes: 17 additions & 2 deletions src/mailers/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
*/
class Users extends \Minz\Mailer
{
private string $logo_cid;

public function __construct()
{
parent::__construct();

$logo_path = \App\Configuration::$app_path . '/public/static/logo.svg';
$this->logo_cid = md5($logo_path);
$this->mailer->addEmbeddedImage($logo_path, $this->logo_cid);
}

/**
* Send an email to given user to validate its account.
*/
Expand All @@ -35,10 +46,12 @@ public function sendAccountValidationEmail(string $user_id): bool
'mailers/users/account_validation_email.phtml',
'mailers/users/account_validation_email.txt',
[
'logo_cid' => $this->logo_cid,
'username' => $user->username,
'token' => $user->validation_token,
]
);

return $this->send($user->email, $subject);
}

Expand Down Expand Up @@ -66,11 +79,12 @@ public function sendResetPasswordEmail(string $user_id): bool
'mailers/users/reset_password_email.phtml',
'mailers/users/reset_password_email.txt',
[
'brand' => $brand,
'logo_cid' => $this->logo_cid,
'username' => $user->username,
'token' => $user->reset_token,
]
);

return $this->send($user->email, $subject);
}

Expand Down Expand Up @@ -104,10 +118,11 @@ public function sendInactivityEmail(string $user_id): bool
'mailers/users/inactivity_email.phtml',
'mailers/users/inactivity_email.txt',
[
'brand' => $brand,
'logo_cid' => $this->logo_cid,
'username' => $user->username,
]
);

return $this->send($user->email, $subject);
}
}
10 changes: 10 additions & 0 deletions src/utils/additionnal_translations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\utils;

// This file contains translations that are placed in files that POEdit isn't
// able to parse. By listing them manually in this file, POEdit detects them,
// even if this file is never used in the application.

// See src/views/_layouts/emails/default.txt
$t = _('This email has been sent by %s (%s)');
33 changes: 33 additions & 0 deletions src/views/_layouts/emails/default.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
</head>

<body style="font-size: 18px; line-height: 1.3; margin: 0; color: #100f18; font-family: Lucida, Arial, sans-serif; background-color: #efeff8;">
<div style="margin: 30px; text-align: center;">
<img src="cid:<?= $logo_cid ?>" alt="<?= get_app_configuration('brand') ?>" width="200" height="40" style="height: auto; max-width: 200px;">
</div>

<div style="max-width: 525px; margin: 20px auto; padding: 30px; background-color: #fff; border-radius: 5px;">
<p>
<?= _f('Hello %s,', $username) ?>
</p>

<?= $this->safe('content') ?>

<p>
<?= _('Best regards,') ?>
</p>

<p>
<?= _f('The %s robot', get_app_configuration('brand')) ?>
</p>
</div>

<p style="text-align: center; color: #4f4e5e; font-size: 14px;">
<?= _f('This email has been sent by <a href="%s" style="color: #4f4e5e;">%s</a>.', url_full('home'), get_app_configuration('brand')) ?>
</p>
</body>
</html>
12 changes: 12 additions & 0 deletions src/views/_layouts/emails/default.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?= _f('Hello %s,', $username) ?>

<?= $content ?>


<?= _('Best regards,') ?>

<?= _f('The %s robot', get_app_configuration('brand')) ?>


--
<?= _f('This email has been sent by %s (%s)', get_app_configuration('brand'), url_full('home')) ?>
11 changes: 4 additions & 7 deletions src/views/mailers/support/notification.phtml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<p>
<?= _('Hello,') ?>
</p>
<?php $this->layout('emails/default.phtml', [
'username' => $username,
'logo_cid' => $logo_cid,
]) ?>

<p>
<?= _f('Your message named “%s” has been sent. Someone will reply to you as soon as possible!', $subject) ?>
</p>

<p>
<?= _f('Transactionally yours, the %s bot', get_app_configuration('brand')) ?>
</p>
8 changes: 3 additions & 5 deletions src/views/mailers/support/notification.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?= _('Hello,') ?>

<?php $this->layout('emails/default.txt', [
'username' => $username,
]) ?>

<?= _f('Your message named “%s” has been sent. Someone will reply to you as soon as possible!', $subject) ?>


<?= _f('Transactionally yours, the %s bot', get_app_configuration('brand')) ?>
11 changes: 4 additions & 7 deletions src/views/mailers/users/account_validation_email.phtml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<p>
<?= _f('Welcome %s,', $username) ?>
</p>
<?php $this->layout('emails/default.phtml', [
'username' => $username,
'logo_cid' => $logo_cid,
]) ?>

<p>
<?= _f('Thank you for your inscription on %s. To finish, you’ll have to confirm your email address. You just have to click on the following link, and you should be all good then:', url_full('home')) ?></br />
<a href="<?= url_full('account validation', ['t' => $token]) ?>">
<?= url_full('account validation', ['t' => $token]) ?>
</a>
</p>

<p>
<?= _('Have a nice day!') ?>
</p>
8 changes: 3 additions & 5 deletions src/views/mailers/users/account_validation_email.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?= _f('Welcome %s,', $username) ?>

<?php $this->layout('emails/default.txt', [
'username' => $username,
]) ?>

<?= _f('Thank you for your inscription on %s. To finish, you’ll have to confirm your email address. You just have to click on the following link, and you should be all good then:', url_full('home')) ?>


<?= url_full('account validation', ['t' => $token]) ?>


<?= _('Have a nice day!') ?>
15 changes: 4 additions & 11 deletions src/views/mailers/users/inactivity_email.phtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<p>
<?= _f('Hello %s,', $username) ?>
</p>
<?php $this->layout('emails/default.phtml', [
'username' => $username,
'logo_cid' => $logo_cid,
]) ?>

<p>
<?= _f('You receive this email because you haven’t been active on %s for several months. To avoid storing outdated data, your account will be deleted after one month. If you don’t want to keep it, you don’t have to do anything. However, if you wish to keep your account, you should login to %s by clicking on the following link:', get_app_configuration('brand'), get_app_configuration('brand')) ?></br />
Expand All @@ -12,11 +13,3 @@
<p>
<?= _('Note that you will not receive any further notification that your account will be deleted.'); ?>
</p>

<p>
<?= _('Best regards,') ?>
</p>

<p>
<?= _f('The %s robot', get_app_configuration('brand')) ?>
</p>
Loading

0 comments on commit 7c9447d

Please sign in to comment.