From 215562ab74fbd443c78e40a851468be9ee4d21b4 Mon Sep 17 00:00:00 2001 From: aina esokia Date: Wed, 3 Feb 2021 11:44:42 +0300 Subject: [PATCH] PHRAS-3256 take in account langage in mail --- .../Phrasea/Authentication/RecoveryService.php | 4 ++++ .../Command/SendValidationRemindersCommand.php | 6 ++++++ .../Phrasea/Command/User/UserCreateCommand.php | 8 ++++++++ .../Command/User/UserPasswordCommand.php | 4 ++++ .../Phrasea/Controller/Admin/UserController.php | 4 ++++ .../Controller/Prod/BasketController.php | 7 +++++++ .../Controller/Root/AccountController.php | 11 +++++++++++ .../Phrasea/Controller/Root/LoginController.php | 10 ++++++++++ .../Core/Event/Subscriber/BasketSubscriber.php | 6 ++++++ .../Core/Event/Subscriber/BridgeSubscriber.php | 5 +++++ .../Event/Subscriber/FeedEntrySubscriber.php | 4 ++++ .../Core/Event/Subscriber/LazaretSubscriber.php | 5 +++++ .../Event/Subscriber/RegistrationSubscriber.php | 17 ++++++++++++++--- .../Event/Subscriber/ValidationSubscriber.php | 12 ++++++++++++ lib/Alchemy/Phrasea/Helper/User/Edit.php | 10 ++++++++++ lib/Alchemy/Phrasea/Helper/User/Manage.php | 8 ++++++++ .../Phrasea/Notification/Mail/AbstractMail.php | 13 +++++++++++++ .../Mail/MailInfoBridgeUploadFailed.php | 4 ++-- .../Notification/Mail/MailInfoNewOrder.php | 6 +++--- .../Mail/MailInfoNewPublication.php | 6 +++--- .../Mail/MailInfoOrderCancelled.php | 6 +++--- .../Mail/MailInfoOrderDelivered.php | 6 +++--- .../Notification/Mail/MailInfoPushReceived.php | 6 +++--- .../Mail/MailInfoRecordQuarantined.php | 6 +++--- .../Mail/MailInfoReminderFeedback.php | 4 ++-- .../Mail/MailInfoSomebodyAutoregistered.php | 6 +++--- .../Mail/MailInfoUserRegistered.php | 6 +++--- .../Mail/MailInfoValidationDone.php | 6 +++--- .../Mail/MailInfoValidationReminder.php | 6 +++--- .../Mail/MailInfoValidationRequest.php | 8 ++++---- .../Phrasea/Notification/Mail/MailInterface.php | 15 +++++++++++++++ .../Notification/Mail/MailRecordsExport.php | 4 ++-- .../Mail/MailRequestAccountDelete.php | 6 +++--- .../Mail/MailRequestEmailConfirmation.php | 6 +++--- .../Mail/MailRequestEmailUpdate.php | 6 +++--- .../Mail/MailRequestPasswordSetup.php | 8 ++++---- .../Mail/MailRequestPasswordUpdate.php | 8 ++++---- .../Mail/MailSuccessAccountDelete.php | 4 ++-- .../MailSuccessEmailConfirmationRegistered.php | 6 +++--- ...MailSuccessEmailConfirmationUnregistered.php | 8 ++++---- .../Mail/MailSuccessEmailUpdate.php | 6 +++--- .../Order/ValidationNotifier/MailNotifier.php | 16 ++++++++++++++++ .../WorkerManager/Worker/ExportMailWorker.php | 13 +++++++++++++ .../Worker/ValidationReminderWorker.php | 6 ++++++ templates/web/email-template.html.twig | 10 +++++----- 45 files changed, 255 insertions(+), 77 deletions(-) diff --git a/lib/Alchemy/Phrasea/Authentication/RecoveryService.php b/lib/Alchemy/Phrasea/Authentication/RecoveryService.php index cfa1075768..5dea04a657 100644 --- a/lib/Alchemy/Phrasea/Authentication/RecoveryService.php +++ b/lib/Alchemy/Phrasea/Authentication/RecoveryService.php @@ -130,6 +130,10 @@ class RecoveryService $mail->setButtonUrl($url); $mail->setExpiration($token->getExpiration()); + if (($locale = $user->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->mailer->deliver($mail); } diff --git a/lib/Alchemy/Phrasea/Command/SendValidationRemindersCommand.php b/lib/Alchemy/Phrasea/Command/SendValidationRemindersCommand.php index 424b06610a..0d45250a8e 100644 --- a/lib/Alchemy/Phrasea/Command/SendValidationRemindersCommand.php +++ b/lib/Alchemy/Phrasea/Command/SendValidationRemindersCommand.php @@ -294,6 +294,12 @@ class SendValidationRemindersCommand extends Command $mail->setButtonUrl($params['url']); $mail->setTitle($title); + if (($locale = $user_to->getLocale()) != null) { + $mail->setLocale($locale); + } elseif (($locale1 = $user_from->getLocale()) != null) { + $mail->setLocale($locale1); + } + $this->deliver($mail); $mailed = true; diff --git a/lib/Alchemy/Phrasea/Command/User/UserCreateCommand.php b/lib/Alchemy/Phrasea/Command/User/UserCreateCommand.php index 66a33f1916..a296e64a39 100644 --- a/lib/Alchemy/Phrasea/Command/User/UserCreateCommand.php +++ b/lib/Alchemy/Phrasea/Command/User/UserCreateCommand.php @@ -187,6 +187,10 @@ class UserCreateCommand extends Command $mail->setButtonUrl('http://'.$servername.'/login/renew-password/?token='.$token->getValue()); $mail->setLogin($user->getLogin()); + if (($locale = $user->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->deliver($mail); } @@ -205,6 +209,10 @@ class UserCreateCommand extends Command $mail->setButtonUrl('http://'.$servername.'/login/register-confirm/?code='.$token->getValue()); $mail->setExpiration($token->getExpiration()); + if (($locale = $user->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->deliver($mail); } diff --git a/lib/Alchemy/Phrasea/Command/User/UserPasswordCommand.php b/lib/Alchemy/Phrasea/Command/User/UserPasswordCommand.php index 94e400aa14..4c0fbba765 100644 --- a/lib/Alchemy/Phrasea/Command/User/UserPasswordCommand.php +++ b/lib/Alchemy/Phrasea/Command/User/UserPasswordCommand.php @@ -172,6 +172,10 @@ class UserPasswordCommand extends Command $mail->setLogin($user->getLogin()); $mail->setExpiration(new \DateTime('+1 day')); + if (($locale = $user->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->deliver($mail); } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/UserController.php b/lib/Alchemy/Phrasea/Controller/Admin/UserController.php index a1487603d8..3e02c1cf19 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/UserController.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/UserController.php @@ -531,6 +531,10 @@ class UserController extends Controller $receiver = new Receiver(null, $user->getEmail()); $mail = MailSuccessEmailUpdate::create($this->app, $receiver, null, $message); + if (($locale = $user->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->deliver($mail); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php b/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php index 6d55dac8e0..010519ed26 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php @@ -76,6 +76,7 @@ class BasketController extends Controller $userFrom = $basket->getValidation()->getInitiator(); $emitter = Emitter::fromUser($userFrom); + $localeFrom = $userFrom->getLocale(); $params = $request->request->all(); $message = $params['reminder-message']; @@ -113,6 +114,12 @@ class BasketController extends Controller $mail->setTitle($basket->getName()); $mail->setButtonUrl($url); + if (($locale = $userTo->getLocale()) != null) { + $mail->setLocale($locale); + } elseif ($localeFrom != null) { + $mail->setLocale($localeFrom); + } + $this->deliver($mail); } diff --git a/lib/Alchemy/Phrasea/Controller/Root/AccountController.php b/lib/Alchemy/Phrasea/Controller/Root/AccountController.php index e5d988cc01..304d8a7bcc 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/AccountController.php +++ b/lib/Alchemy/Phrasea/Controller/Root/AccountController.php @@ -129,6 +129,10 @@ class AccountController extends Controller $mail->setButtonUrl($url); $mail->setExpiration($token->getExpiration()); + if (($locale = $user->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->deliver($mail); $this->app->addFlash('info', $this->app->trans('admin::compte-utilisateur un email de confirmation vient de vous etre envoye. Veuillez suivre les instructions contenue pour continuer')); @@ -355,6 +359,10 @@ class AccountController extends Controller $mail->setButtonUrl($url); $mail->setExpiration($token->getExpiration()); + if (($locale = $user->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->deliver($mail); $this->app->addFlash('info', $this->app->trans('phraseanet::account: A confirmation e-mail has been sent. Please follow the instructions contained to continue account deletion')); @@ -546,6 +554,9 @@ class AccountController extends Controller $this->app['manipulator.user']->delete($user, [$user->getId() => $oldGrantedBaseIds]); if($mail) { + if (($locale = $user->getLocale()) != null) { + $mail->setLocale($locale); + } $this->deliver($mail); } diff --git a/lib/Alchemy/Phrasea/Controller/Root/LoginController.php b/lib/Alchemy/Phrasea/Controller/Root/LoginController.php index 8c02a62416..5441a50912 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/LoginController.php +++ b/lib/Alchemy/Phrasea/Controller/Root/LoginController.php @@ -369,11 +369,21 @@ class LoginController extends Controller if (count($this->getAclForUser($user)->get_granted_base()) > 0) { $mail = MailSuccessEmailConfirmationRegistered::create($this->app, $receiver); + + if (($locale = $user->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->deliver($mail); $this->app->addFlash('success', $this->app->trans('Account has been unlocked, you can now login.')); } else { $mail = MailSuccessEmailConfirmationUnregistered::create($this->app, $receiver); + + if (($locale = $user->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->deliver($mail); $this->app->addFlash('info', $this->app->trans('Account has been unlocked, you still have to wait for admin approval.')); diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/BasketSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/BasketSubscriber.php index b7f0706c54..3a4ff0af65 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/BasketSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/BasketSubscriber.php @@ -45,6 +45,12 @@ class BasketSubscriber extends AbstractNotificationSubscriber $mail->setBasket($basket); $mail->setPusher($user_from); + if (($locale = $user_to->getLocale()) != null) { + $mail->setLocale($locale); + } elseif (($locale1 = $user_from->getLocale()) != null) { + $mail->setLocale($locale1); + } + $this->deliver($mail, $event->hasReceipt()); $mailed = true; diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/BridgeSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/BridgeSubscriber.php index 0de92461df..66f87d04f1 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/BridgeSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/BridgeSubscriber.php @@ -46,6 +46,11 @@ class BridgeSubscriber extends AbstractNotificationSubscriber $mail = MailInfoBridgeUploadFailed::create($this->app, $receiver); $mail->setAdapter($account->get_api()->get_connector()->get_name()); $mail->setReason($params['reason']); + + if (($locale = $user->getLocale()) != null) { + $mail->setlocale($locale); + } + $this->deliver($mail); $mailed = true; } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/FeedEntrySubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/FeedEntrySubscriber.php index e229cc3f44..c0a0f5f722 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/FeedEntrySubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/FeedEntrySubscriber.php @@ -79,6 +79,10 @@ class FeedEntrySubscriber extends AbstractNotificationSubscriber $mail->setAuthor($entry->getAuthorName()); $mail->setTitle($entry->getTitle()); + if (($locale = $token->getUser()->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->deliver($mail); $users_emailed[$token->getUser()->getId()] = true; } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/LazaretSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/LazaretSubscriber.php index 0db6fa8794..5c3903c098 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/LazaretSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/LazaretSubscriber.php @@ -63,6 +63,11 @@ class LazaretSubscriber extends AbstractNotificationSubscriber if ($readyToSend) { $mail = MailInfoRecordQuarantined::create($this->app, $receiver); + + if (($locale = $user->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->deliver($mail); $mailed = true; } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/RegistrationSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/RegistrationSubscriber.php index 03349aa75d..e1cad62cc5 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/RegistrationSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/RegistrationSubscriber.php @@ -56,6 +56,10 @@ class RegistrationSubscriber extends AbstractNotificationSubscriber $mail = MailInfoUserRegistered::create($this->app, $receiver); $mail->setRegisteredUser($registeredUser); + if (($locale = $adminUser->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->deliver($mail); $mailed = true; @@ -104,11 +108,13 @@ class RegistrationSubscriber extends AbstractNotificationSubscriber private function autoregisterEMail(User $to, User $registeredUser) { + $locale = ($to->getLocale() != null)? $to->getLocale() : null; + $body = ''; $body .= sprintf("Login : %s\n", $registeredUser->getLogin()); - $body .= sprintf("%s : %s\n", $this->app->trans('admin::compte-utilisateur nom'), $registeredUser->getFirstName()); - $body .= sprintf("%s : %s\n", $this->app->trans('admin::compte-utilisateur prenom'), $registeredUser->getLastName()); - $body .= sprintf("%s : %s\n", $this->app->trans('admin::compte-utilisateur email'), $registeredUser->getEmail()); + $body .= sprintf("%s : %s\n", $this->app->trans('admin::compte-utilisateur nom', [], 'messages', $locale), $registeredUser->getFirstName()); + $body .= sprintf("%s : %s\n", $this->app->trans('admin::compte-utilisateur prenom', [], 'messages', $locale), $registeredUser->getLastName()); + $body .= sprintf("%s : %s\n", $this->app->trans('admin::compte-utilisateur email', [], 'messages', $locale), $registeredUser->getEmail()); $body .= sprintf("%s/%s\n", $registeredUser->getJob(), $registeredUser->getCompany()); $readyToSend = false; @@ -121,6 +127,11 @@ class RegistrationSubscriber extends AbstractNotificationSubscriber if ($readyToSend) { $mail = MailInfoSomebodyAutoregistered::create($this->app, $receiver, null, $body); + + if ($locale != null) { + $mail->setLocale($locale); + } + $this->deliver($mail); } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ValidationSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ValidationSubscriber.php index 9f788c115b..6221f8e7bf 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ValidationSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ValidationSubscriber.php @@ -57,6 +57,12 @@ class ValidationSubscriber extends AbstractNotificationSubscriber $mail->setTitle($title); $mail->setUser($user_from); + if (($locale = $user_to->getLocale()) != null) { + $mail->setLocale($locale); + } elseif (($locale1 = $user_from->getLocale()) != null) { + $mail->setLocale($locale1); + } + $this->deliver($mail, $event->hasReceipt()); $mailed = true; } @@ -100,6 +106,12 @@ class ValidationSubscriber extends AbstractNotificationSubscriber $mail->setTitle($title); $mail->setUser($user_from); + if (($locale = $user_to->getLocale()) != null) { + $mail->setLocale($locale); + } elseif (($locale1 = $user_from->getLocale()) != null) { + $mail->setLocale($locale1); + } + $this->deliver($mail); $mailed = true; } diff --git a/lib/Alchemy/Phrasea/Helper/User/Edit.php b/lib/Alchemy/Phrasea/Helper/User/Edit.php index 69db5823b0..f668be56c7 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/User/Edit.php @@ -679,6 +679,11 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper if ($oldReceiver) { $mailOldAddress = MailSuccessEmailUpdate::create($this->app, $oldReceiver, null, $this->app->trans('You will now receive notifications at %new_email%', ['%new_email%' => $new_email])); + + if (($locale = $user->getLocale()) != null) { + $mailOldAddress->setLocale($locale); + } + $this->deliver($mailOldAddress); } @@ -690,6 +695,11 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper if ($newReceiver) { $mailNewAddress = MailSuccessEmailUpdate::create($this->app, $newReceiver, null, $this->app->trans('You will no longer receive notifications at %old_email%', ['%old_email%' => $old_email])); + + if (($locale = $user->getLocale()) != null) { + $mailNewAddress->setLocale($locale); + } + $this->deliver($mailNewAddress); } } diff --git a/lib/Alchemy/Phrasea/Helper/User/Manage.php b/lib/Alchemy/Phrasea/Helper/User/Manage.php index ecaa32547b..09e37caf2e 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Manage.php +++ b/lib/Alchemy/Phrasea/Helper/User/Manage.php @@ -195,6 +195,10 @@ class Manage extends Helper $mail->setButtonUrl($this->app->url('login_register_confirm', ['code' => $token->getValue()])); $mail->setExpiration($token->getExpiration()); + if (($locale = $user->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->deliver($mail); } @@ -208,6 +212,10 @@ class Manage extends Helper $mail->setButtonUrl($this->app->url('login_renew_password', ['token' => $token->getValue()])); $mail->setLogin($user->getLogin()); + if (($locale = $user->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->deliver($mail); } } diff --git a/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php b/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php index 5cf305b912..e2eb7bcaf0 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php @@ -19,6 +19,8 @@ abstract class AbstractMail implements MailInterface { const MAIL_SKIN = 'default'; + /** @var string| null */ + protected $locale = null; /** @var Application */ protected $app; /** @var EmitterInterface */ @@ -62,6 +64,7 @@ abstract class AbstractMail implements MailInterface 'buttonUrl' => $this->getButtonURL(), 'buttonText' => $this->getButtonText(), 'mailSkin' => $this->getMailSkin(), + 'emailLocale' => $this->getLocale() ]); } @@ -81,6 +84,16 @@ abstract class AbstractMail implements MailInterface return $this->app->url('root'); } + public function getLocale() + { + return $this->locale; + } + + public function setLocale($locale) + { + $this->locale = $locale; + } + /** * {@inheritdoc} */ diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoBridgeUploadFailed.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoBridgeUploadFailed.php index c13f2ddc90..b93a5e56b8 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoBridgeUploadFailed.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoBridgeUploadFailed.php @@ -45,7 +45,7 @@ class MailInfoBridgeUploadFailed extends AbstractMailWithLink */ public function getSubject() { - return $this->app->trans('Upload failed on %application%', ['%application%' => $this->getPhraseanetTitle()]); + return $this->app->trans('Upload failed on %application%', ['%application%' => $this->getPhraseanetTitle()], 'messages', $this->getLocale()); } /** @@ -60,7 +60,7 @@ class MailInfoBridgeUploadFailed extends AbstractMailWithLink throw new LogicException('You must set a reason before calling getMessage'); } - return $this->app->trans('An upload on %bridge_adapter% failed, the resaon is : %reason%', ['%bridge_adapter%' => $this->adapter, '%reason%' => $this->reason]); + return $this->app->trans('An upload on %bridge_adapter% failed, the resaon is : %reason%', ['%bridge_adapter%' => $this->adapter, '%reason%' => $this->reason], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php index 5c9c23d65e..6c83966185 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php @@ -34,7 +34,7 @@ class MailInfoNewOrder extends AbstractMail */ public function getSubject() { - return $this->app->trans('admin::register: Nouvelle commande sur %application%', ['%application%' => $this->getPhraseanetTitle()]); + return $this->app->trans('admin::register: Nouvelle commande sur %application%', ['%application%' => $this->getPhraseanetTitle()], 'messages', $this->getLocale()); } /** @@ -46,7 +46,7 @@ class MailInfoNewOrder extends AbstractMail throw new LogicException('You must set a user before calling getMessage()'); } - return $this->app->trans('%user% has ordered documents', ['%user%' => $this->user->getDisplayName()]); + return $this->app->trans('%user% has ordered documents', ['%user%' => $this->user->getDisplayName()], 'messages', $this->getLocale()); } /** @@ -54,7 +54,7 @@ class MailInfoNewOrder extends AbstractMail */ public function getButtonText() { - return $this->app->trans('Review order on %website%', ['%website%' => $this->getPhraseanetTitle()]); + return $this->app->trans('Review order on %website%', ['%website%' => $this->getPhraseanetTitle()], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewPublication.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewPublication.php index 3c6b0e11a1..94cdfd99dc 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewPublication.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewPublication.php @@ -49,7 +49,7 @@ class MailInfoNewPublication extends AbstractMailWithLink throw new LogicException('You must set an title before calling getMessage'); } - return $this->app->trans('Nouvelle publication : %title%', ['%title%' => $this->title]); + return $this->app->trans('Nouvelle publication : %title%', ['%title%' => $this->title], 'messages', $this->getLocale()); } /** @@ -64,7 +64,7 @@ class MailInfoNewPublication extends AbstractMailWithLink throw new LogicException('You must set an title before calling getMessage'); } - return $this->app->trans('%user% vient de publier %title%', ['%user%' => $this->author, '%title%' => $this->title]); + return $this->app->trans('%user% vient de publier %title%', ['%user%' => $this->author, '%title%' => $this->title], 'messages', $this->getLocale()); } /** @@ -72,7 +72,7 @@ class MailInfoNewPublication extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('View on %title%', ['%title%' => $this->getPhraseanetTitle()]); + return $this->app->trans('View on %title%', ['%title%' => $this->getPhraseanetTitle()], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php index 010849f6c6..be513109b9 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php @@ -46,7 +46,7 @@ class MailInfoOrderCancelled extends AbstractMail */ public function getSubject() { - return $this->app->trans('push::mail:: Refus d\'elements de votre commande'); + return $this->app->trans('push::mail:: Refus d\'elements de votre commande', [], 'messages', $this->getLocale()); } /** @@ -64,7 +64,7 @@ class MailInfoOrderCancelled extends AbstractMail return $this->app->trans('%user% a refuse %quantity% elements de votre commande', [ '%user%' => $this->deliverer->getDisplayName(), '%quantity%' => $this->quantity, - ]); + ], 'messages', $this->getLocale()); } /** @@ -72,7 +72,7 @@ class MailInfoOrderCancelled extends AbstractMail */ public function getButtonText() { - return $this->app->trans('See my order'); + return $this->app->trans('See my order', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php index 33e0a5ed8e..74b1032f86 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php @@ -51,7 +51,7 @@ class MailInfoOrderDelivered extends AbstractMail throw new LogicException('You must set a basket before calling getSubject'); } - return $this->app->trans('push::mail:: Reception de votre commande %title%', ['%title%' => $this->basket->getName()]); + return $this->app->trans('push::mail:: Reception de votre commande %title%', ['%title%' => $this->basket->getName()], 'messages', $this->getLocale()); } /** @@ -63,7 +63,7 @@ class MailInfoOrderDelivered extends AbstractMail throw new LogicException('You must set a deliverer before calling getMessage'); } - return $this->app->trans('%user% vous a delivre votre commande, consultez la en ligne a l\'adresse suivante', ['%user%' => $this->deliverer->getDisplayName()]); + return $this->app->trans('%user% vous a delivre votre commande, consultez la en ligne a l\'adresse suivante', ['%user%' => $this->deliverer->getDisplayName()], 'messages', $this->getLocale()); } /** @@ -71,7 +71,7 @@ class MailInfoOrderDelivered extends AbstractMail */ public function getButtonText() { - return $this->app->trans('See my order'); + return $this->app->trans('See my order', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php index 605bb4d5f8..4086e627e6 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php @@ -46,7 +46,7 @@ class MailInfoPushReceived extends AbstractMailWithLink throw new LogicException('You must set a basket before calling getSubject'); } - return $this->app->trans('Reception of %basket_name%', ['%basket_name%' => $this->basket->getName()]); + return $this->app->trans('Reception of %basket_name%', ['%basket_name%' => $this->basket->getName()], 'messages', $this->getLocale()); } /** @@ -62,7 +62,7 @@ class MailInfoPushReceived extends AbstractMailWithLink } return - $this->app->trans('You just received a push containing %quantity% documents from %user%', ['%quantity%' => count($this->basket->getElements()), '%user%' => $this->pusher->getDisplayName()]) + $this->app->trans('You just received a push containing %quantity% documents from %user%', ['%quantity%' => count($this->basket->getElements()), '%user%' => $this->pusher->getDisplayName()], 'messages', $this->getLocale()) . "\n" . $this->message; } @@ -71,7 +71,7 @@ class MailInfoPushReceived extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('Watch it online'); + return $this->app->trans('Watch it online', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoRecordQuarantined.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoRecordQuarantined.php index 5f091b40be..f2da54c51d 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoRecordQuarantined.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoRecordQuarantined.php @@ -18,7 +18,7 @@ class MailInfoRecordQuarantined extends AbstractMail */ public function getSubject() { - return $this->app->trans('A document has been quarantined'); + return $this->app->trans('A document has been quarantined', [], 'messages', $this->getLocale()); } /** @@ -26,7 +26,7 @@ class MailInfoRecordQuarantined extends AbstractMail */ public function getMessage() { - return $this->app->trans('A file has been thrown to the quarantine.'); + return $this->app->trans('A file has been thrown to the quarantine.', [], 'messages', $this->getLocale()); } /** @@ -34,7 +34,7 @@ class MailInfoRecordQuarantined extends AbstractMail */ public function getButtonText() { - return $this->app->trans('Access quarantine'); + return $this->app->trans('Access quarantine', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoReminderFeedback.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoReminderFeedback.php index d4f5bde01c..5e8b87e88a 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoReminderFeedback.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoReminderFeedback.php @@ -28,7 +28,7 @@ class MailInfoReminderFeedback extends AbstractMailWithLink throw new LogicException('You must set an title before calling getSubject'); } - return $this->app->trans("Manual feedback Reminder : '%title%'", ['%title%' => $this->title]); + return $this->app->trans("Manual feedback Reminder : '%title%'", ['%title%' => $this->title], 'messages', $this->getLocale()); } /** @@ -44,7 +44,7 @@ class MailInfoReminderFeedback extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('Start validation'); + return $this->app->trans('Start validation', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php index 95347c5ce7..a3f4e2696f 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php @@ -18,7 +18,7 @@ class MailInfoSomebodyAutoregistered extends AbstractMailWithLink */ public function getSubject() { - return $this->app->trans('admin::register: Inscription automatique sur %application%', ['%application%' => $this->getPhraseanetTitle()]); + return $this->app->trans('admin::register: Inscription automatique sur %application%', ['%application%' => $this->getPhraseanetTitle()], 'messages', $this->getLocale()); } /** @@ -26,7 +26,7 @@ class MailInfoSomebodyAutoregistered extends AbstractMailWithLink */ public function getMessage() { - return $this->app->trans('admin::register: un utilisateur s\'est inscrit')."\n\n".$this->message; + return $this->app->trans('admin::register: un utilisateur s\'est inscrit', [], 'messages', $this->getLocale())."\n\n".$this->message; } /** @@ -34,7 +34,7 @@ class MailInfoSomebodyAutoregistered extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('Update the account'); + return $this->app->trans('Update the account', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php index b766ce493f..2f6a90c008 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php @@ -34,7 +34,7 @@ class MailInfoUserRegistered extends AbstractMail */ public function getSubject() { - return $this->app->trans('admin::register: demande d\'inscription sur %application%', ['%application%' => $this->getPhraseanetTitle()]); + return $this->app->trans('admin::register: demande d\'inscription sur %application%', ['%application%' => $this->getPhraseanetTitle()], 'messages', $this->getLocale()); } /** @@ -46,7 +46,7 @@ class MailInfoUserRegistered extends AbstractMail throw new LogicException('You must set a user before calling getMessage'); } - return $this->app->trans('admin::register: un utilisateur a fait une demande d\'inscription') + return $this->app->trans('admin::register: un utilisateur a fait une demande d\'inscription', [], 'messages', $this->getLocale()) . "\n\n" . sprintf('%s %s',$this->registeredUser->getFirstName(), $this->registeredUser->getLastName()) . "\n\n" . sprintf('%s %s',$this->registeredUser->getJob(), $this->registeredUser->getCompany()); } @@ -56,7 +56,7 @@ class MailInfoUserRegistered extends AbstractMail */ public function getButtonText() { - return $this->app->trans('Process the registration'); + return $this->app->trans('Process the registration', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php index 0ced543d4a..67ff18d67f 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php @@ -56,7 +56,7 @@ class MailInfoValidationDone extends AbstractMailWithLink return $this->app->trans('push::mail:: Rapport de validation de %user% pour %title%', [ '%user%' => $this->user->getDisplayName(), '%title%' => $this->title, - ]); + ], 'messages', $this->getLocale()); } /** @@ -70,7 +70,7 @@ class MailInfoValidationDone extends AbstractMailWithLink return $this->app->trans('%user% has just sent its validation report, you can now see it', [ '%user%' => $this->user->getDisplayName(), - ]); + ], 'messages', $this->getLocale()); } /** @@ -78,7 +78,7 @@ class MailInfoValidationDone extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('See validation results'); + return $this->app->trans('See validation results', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationReminder.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationReminder.php index d8b0305c3f..eda4e39afa 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationReminder.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationReminder.php @@ -49,7 +49,7 @@ class MailInfoValidationReminder extends AbstractMailWithLink throw new LogicException('You must set an title before calling getSubject'); } - return $this->app->trans("Reminder : validate '%title%'", ['%title%' => $this->title]); + return $this->app->trans("Reminder : validate '%title%'", ['%title%' => $this->title], 'messages', $this->getLocale()); } /** @@ -59,7 +59,7 @@ class MailInfoValidationReminder extends AbstractMailWithLink { return $this->app->trans('Il ne vous reste plus que %timeLeft% pour terminer votre validation', [ '%timeLeft%' => isset($this->timeLeft)? $this->timeLeft : '' - ]); + ], 'messages', $this->getLocale()); } /** @@ -67,7 +67,7 @@ class MailInfoValidationReminder extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('Start validation'); + return $this->app->trans('Start validation', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php index d4c916cf6a..cfa4206854 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php @@ -60,7 +60,7 @@ class MailInfoValidationRequest extends AbstractMailWithLink throw new LogicException('You must set a title before calling getSubject'); } - return $this->app->trans("Validation request from %user% for '%title%'", ['%user%' => $this->user->getDisplayName(), '%title%' => $this->title]); + return $this->app->trans("Validation request from %user% for '%title%'", ['%user%' => $this->user->getDisplayName(), '%title%' => $this->title], 'messages', $this->getLocale()); } /** @@ -70,9 +70,9 @@ class MailInfoValidationRequest extends AbstractMailWithLink { if (0 < $this->duration) { if (1 < $this->duration) { - return $this->message . "\n\n" . $this->app->trans("You have %quantity% days to validate the selection.", ['%quantity%' => $this->duration]); + return $this->message . "\n\n" . $this->app->trans("You have %quantity% days to validate the selection.", ['%quantity%' => $this->duration], 'messages', $this->getLocale()); } else { - return $this->message . "\n\n" . $this->app->trans("You have 1 day to validate the selection."); + return $this->message . "\n\n" . $this->app->trans("You have 1 day to validate the selection.", [], 'messages', $this->getLocale()); } } @@ -84,7 +84,7 @@ class MailInfoValidationRequest extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('Start validation'); + return $this->app->trans('Start validation', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInterface.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInterface.php index c99817fa30..b5018efd91 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInterface.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInterface.php @@ -85,6 +85,21 @@ interface MailInterface */ public function getPhraseanetURL(); + /** + * Set the locale for the email text + * + * @param $locale + * @return string + */ + public function setLocale($locale); + + /** + * Get the locale + * + * @return string + */ + public function getLocale(); + /** * Returns an URL for a logo * diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRecordsExport.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRecordsExport.php index 036600f9f3..09a695a052 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailRecordsExport.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRecordsExport.php @@ -18,7 +18,7 @@ class MailRecordsExport extends AbstractMailWithLink */ public function getSubject() { - return $this->app->trans('Vous avez recu des documents'); + return $this->app->trans('Vous avez recu des documents', [], 'messages', $this->getLocale()); } /** @@ -34,7 +34,7 @@ class MailRecordsExport extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('Download'); + return $this->app->trans('Download', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestAccountDelete.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestAccountDelete.php index 56998f0a0f..6b4ad5ce1e 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestAccountDelete.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestAccountDelete.php @@ -36,7 +36,7 @@ class MailRequestAccountDelete extends AbstractMailWithLink */ public function getSubject() { - return $this->app->trans('Email:deletion:request:subject Delete account confirmation'); + return $this->app->trans('Email:deletion:request:subject Delete account confirmation', [], 'messages', $this->getLocale()); } /** @@ -57,7 +57,7 @@ class MailRequestAccountDelete extends AbstractMailWithLink '%lastName%' => $this->user->getLastName(), '%urlInstance%' => ''.$this->getPhraseanetURL().'', '%resetPassword%' => ''.$this->app->url('reset_password').'', - ]); + ], 'messages', $this->getLocale()); } /** @@ -65,7 +65,7 @@ class MailRequestAccountDelete extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('Email:deletion:request:textButton Delete my account'); + return $this->app->trans('Email:deletion:request:textButton Delete my account', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailConfirmation.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailConfirmation.php index f86c699705..fb52bbf51d 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailConfirmation.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailConfirmation.php @@ -18,7 +18,7 @@ class MailRequestEmailConfirmation extends AbstractMailWithLink */ public function getSubject() { - return $this->app->trans('login::register: sujet email : confirmation de votre adresse email'); + return $this->app->trans('login::register: sujet email : confirmation de votre adresse email', [], 'messages', $this->getLocale()); } /** @@ -26,7 +26,7 @@ class MailRequestEmailConfirmation extends AbstractMailWithLink */ public function getMessage() { - return $this->app->trans('login::register: email confirmation email Pour valider votre inscription a la base de donnees, merci de confirmer votre e-mail en suivant le lien ci-dessous.'); + return $this->app->trans('login::register: email confirmation email Pour valider votre inscription a la base de donnees, merci de confirmer votre e-mail en suivant le lien ci-dessous.', [], 'messages', $this->getLocale()); } /** @@ -34,7 +34,7 @@ class MailRequestEmailConfirmation extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('Validate e-mail address'); + return $this->app->trans('Validate e-mail address', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailUpdate.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailUpdate.php index fb5cbeda24..00aa31406e 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailUpdate.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailUpdate.php @@ -18,7 +18,7 @@ class MailRequestEmailUpdate extends AbstractMailWithLink */ public function getSubject() { - return $this->app->trans('login::register: sujet email : confirmation de votre adresse email'); + return $this->app->trans('login::register: sujet email : confirmation de votre adresse email', [], 'messages', $this->getLocale()); } /** @@ -26,7 +26,7 @@ class MailRequestEmailUpdate extends AbstractMailWithLink */ public function getMessage() { - return $this->app->trans('admin::compte-utilisateur: email changement de mot d\'email Bonjour, nous avons bien recu votre demande de changement d\'adresse e-mail. Pour la confirmer, veuillez suivre le lien qui suit. SI vous recevez ce mail sans l\'avoir sollicite, merci de le detruire et de l\'ignorer.'); + return $this->app->trans('admin::compte-utilisateur: email changement de mot d\'email Bonjour, nous avons bien recu votre demande de changement d\'adresse e-mail. Pour la confirmer, veuillez suivre le lien qui suit. SI vous recevez ce mail sans l\'avoir sollicite, merci de le detruire et de l\'ignorer.', [], 'messages', $this->getLocale()); } /** @@ -34,7 +34,7 @@ class MailRequestEmailUpdate extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('Confirm new email address'); + return $this->app->trans('Confirm new email address', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordSetup.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordSetup.php index 77c29853e7..fed11d39f4 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordSetup.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordSetup.php @@ -33,7 +33,7 @@ class MailRequestPasswordSetup extends AbstractMailWithLink */ public function getSubject() { - return $this->app->trans('Your account on %application%', ['%application%' => $this->getPhraseanetTitle()]); + return $this->app->trans('Your account on %application%', ['%application%' => $this->getPhraseanetTitle()], 'messages', $this->getLocale()); } /** @@ -45,9 +45,9 @@ class MailRequestPasswordSetup extends AbstractMailWithLink throw new LogicException('You must set a login before calling getMessage'); } - return $this->app->trans('Your account with the login %login% as been created', ['%login%' => $this->login]) + return $this->app->trans('Your account with the login %login% as been created', ['%login%' => $this->login], 'messages', $this->getLocale()) . "\n" - . $this->app->trans('You now have to set up your pasword'); + . $this->app->trans('You now have to set up your pasword', [], 'messages', $this->getLocale()); } /** @@ -55,7 +55,7 @@ class MailRequestPasswordSetup extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('Setup my password'); + return $this->app->trans('Setup my password', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordUpdate.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordUpdate.php index 8b90716e72..27ce59ac42 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordUpdate.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordUpdate.php @@ -33,7 +33,7 @@ class MailRequestPasswordUpdate extends AbstractMailWithLink */ public function getSubject() { - return $this->app->trans('login:: Forgot your password'); + return $this->app->trans('login:: Forgot your password', [], 'messages', $this->getLocale()); } /** @@ -45,9 +45,9 @@ class MailRequestPasswordUpdate extends AbstractMailWithLink throw new LogicException('You must set a login before calling getMessage'); } - return $this->app->trans('Password renewal for login "%login%" has been requested', ['%login%' => $this->login]) + return $this->app->trans('Password renewal for login "%login%" has been requested', ['%login%' => $this->login], 'messages', $this->getLocale()) . "\n" - . $this->app->trans('login:: Visitez le lien suivant et suivez les instructions pour continuer, sinon ignorez cet email et il ne se passera rien'); + . $this->app->trans('login:: Visitez le lien suivant et suivez les instructions pour continuer, sinon ignorez cet email et il ne se passera rien', [], 'messages', $this->getLocale()); } /** @@ -55,7 +55,7 @@ class MailRequestPasswordUpdate extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('Renew password'); + return $this->app->trans('Renew password', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessAccountDelete.php b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessAccountDelete.php index 462feda255..d4ba305748 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessAccountDelete.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessAccountDelete.php @@ -18,7 +18,7 @@ class MailSuccessAccountDelete extends AbstractMail */ public function getSubject() { - return $this->app->trans('Delete account successfull'); + return $this->app->trans('Delete account successfull', [], 'messages', $this->getLocale()); } /** @@ -26,7 +26,7 @@ class MailSuccessAccountDelete extends AbstractMail */ public function getMessage() { - return $this->app->trans('Your phraseanet account on %urlInstance% has been deleted!', ['%urlInstance%' => ''.$this->getPhraseanetURL().'']); + return $this->app->trans('Your phraseanet account on %urlInstance% has been deleted!', ['%urlInstance%' => ''.$this->getPhraseanetURL().''], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationRegistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationRegistered.php index 50606e3d1e..88e34b1af4 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationRegistered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationRegistered.php @@ -18,7 +18,7 @@ class MailSuccessEmailConfirmationRegistered extends AbstractMailWithLink */ public function getSubject() { - return $this->app->trans('Email successfully confirmed'); + return $this->app->trans('Email successfully confirmed', [], 'messages', $this->getLocale()); } /** @@ -26,7 +26,7 @@ class MailSuccessEmailConfirmationRegistered extends AbstractMailWithLink */ public function getMessage() { - return $this->app->trans('login::register: merci d\'avoir confirme votre adresse email'); + return $this->app->trans('login::register: merci d\'avoir confirme votre adresse email', [], 'messages', $this->getLocale()); } /** @@ -34,7 +34,7 @@ class MailSuccessEmailConfirmationRegistered extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('Your access on %application%', ['%application%' => $this->app['conf']->get(['registry', 'general', 'title'])]); + return $this->app->trans('Your access on %application%', ['%application%' => $this->app['conf']->get(['registry', 'general', 'title'])], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationUnregistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationUnregistered.php index d9975f4133..3e844f7daf 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationUnregistered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationUnregistered.php @@ -18,7 +18,7 @@ class MailSuccessEmailConfirmationUnregistered extends AbstractMailWithLink */ public function getSubject() { - return $this->app->trans('Email successfully confirmed'); + return $this->app->trans('Email successfully confirmed', [], 'messages', $this->getLocale()); } /** @@ -26,9 +26,9 @@ class MailSuccessEmailConfirmationUnregistered extends AbstractMailWithLink */ public function getMessage() { - return $this->app->trans('login::register: merci d\'avoir confirme votre adresse email') + return $this->app->trans('login::register: merci d\'avoir confirme votre adresse email', [], 'messages', $this->getLocale()) . "\n" - . $this->app->trans("You have to wait for an administrator approval for your access request"); + . $this->app->trans("You have to wait for an administrator approval for your access request", [], 'messages', $this->getLocale()); } /** @@ -36,7 +36,7 @@ class MailSuccessEmailConfirmationUnregistered extends AbstractMailWithLink */ public function getButtonText() { - return $this->app->trans('Watch my access requests status'); + return $this->app->trans('Watch my access requests status', [], 'messages', $this->getLocale()); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailUpdate.php b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailUpdate.php index 5f1550f94f..29bb0bf62b 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailUpdate.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailUpdate.php @@ -18,7 +18,7 @@ class MailSuccessEmailUpdate extends AbstractMail */ public function getSubject() { - return $this->app->trans('Update of your email address on %application%', ['%application%' => $this->getPhraseanetTitle()]); + return $this->app->trans('Update of your email address on %application%', ['%application%' => $this->getPhraseanetTitle()], 'messages', $this->getLocale()); } /** @@ -27,8 +27,8 @@ class MailSuccessEmailUpdate extends AbstractMail public function getMessage() { return sprintf("%s\n%s\n%s", - $this->app->trans('Dear %user%,', ['%user%' => $this->receiver->getName()]), - $this->app->trans('Your contact email address has been updated'), + $this->app->trans('Dear %user%,', ['%user%' => $this->receiver->getName()], 'messages', $this->getLocale()), + $this->app->trans('Your contact email address has been updated', [], 'messages', $this->getLocale()), $this->message ); } diff --git a/lib/Alchemy/Phrasea/Order/ValidationNotifier/MailNotifier.php b/lib/Alchemy/Phrasea/Order/ValidationNotifier/MailNotifier.php index 9934fafb08..2df7366ac6 100644 --- a/lib/Alchemy/Phrasea/Order/ValidationNotifier/MailNotifier.php +++ b/lib/Alchemy/Phrasea/Order/ValidationNotifier/MailNotifier.php @@ -54,6 +54,10 @@ class MailNotifier implements ValidationNotifier $mail->setUser($order->getUser()); + if (($locale = $recipient->getLocale()) != null) { + $mail->setLocale($locale); + } + $this->getDeliverer()->deliver($mail); } @@ -82,6 +86,12 @@ class MailNotifier implements ValidationNotifier $mail->setBasket($basket); $mail->setDeliverer($delivery->getAdmin()); + if (($locale = $order->getUser()->getLocale()) != null) { + $mail->setLocale($locale); + } elseif (($locale1 = $delivery->getAdmin()->getLocale()) != null) { + $mail->setLocale($locale1); + } + $this->getDeliverer()->deliver($mail); } @@ -99,6 +109,12 @@ class MailNotifier implements ValidationNotifier $mail->setQuantity($delivery->getQuantity()); $mail->setDeliverer($delivery->getAdmin()); + if (($locale = $delivery->getOrder()->getUser()->getLocale()) != null) { + $mail->setLocale($locale); + } elseif (($locale1 = $delivery->getAdmin()->getLocale()) != null) { + $mail->setLocale($locale1); + } + $this->getDeliverer()->deliver($mail); } } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/ExportMailWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/ExportMailWorker.php index 64e569a2df..e5a0576468 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/ExportMailWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/ExportMailWorker.php @@ -71,6 +71,7 @@ class ExportMailWorker implements WorkerInterface $userRepository = $this->app['repo.users']; $user = $userRepository->find($payload['emitterUserId']); + $localeEmitter = $user->getLocale(); /** @var TokenRepository $tokenRepository */ $tokenRepository = $this->app['repo.tokens']; @@ -100,12 +101,24 @@ class ExportMailWorker implements WorkerInterface } catch (InvalidArgumentException $e) { continue; } + + $userTo = $userRepository->findByEmail(trim($mail)); + + $locale = null; + if ($userTo !== null) { + $locale = ($userTo->getLocale() != null) ? $userTo->getLocale() : $localeEmitter; + } + $deliverEmails[] = $mail; $mail = MailRecordsExport::create($this->app, $receiver, $emitter, $params['textmail']); $mail->setButtonUrl($params['url']); $mail->setExpiration($token->getExpiration()); + if ($locale != null) { + $mail->setLocale($locale); + } + $this->deliver($mail, $params['reading_confirm']); unset($remaingEmails[$key]); diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/ValidationReminderWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/ValidationReminderWorker.php index bb6e663a04..da3db801a3 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/ValidationReminderWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/ValidationReminderWorker.php @@ -144,6 +144,12 @@ class ValidationReminderWorker implements WorkerInterface $mail->setButtonUrl($params['url']); $mail->setTitle($title); + if (($locale = $userTo->getLocale()) != null) { + $mail->setLocale($locale); + } elseif (($locale1 = $userFrom->getLocale()) != null) { + $mail->setLocale($locale1); + } + $this->deliver($mail); $mailed = true; diff --git a/templates/web/email-template.html.twig b/templates/web/email-template.html.twig index 6eb1f9c6fb..fa9b42d95e 100644 --- a/templates/web/email-template.html.twig +++ b/templates/web/email-template.html.twig @@ -25,7 +25,7 @@ @@ -112,7 +112,7 @@ {% if expiration is not none %} {% endif %} @@ -122,7 +122,7 @@
- {{ 'Si cet email contient des liens non cliquables, copiez/collez ces liens dans votre navigateur.' | trans }} + {{ 'Si cet email contient des liens non cliquables, copiez/collez ces liens dans votre navigateur.' | trans({}, "messages", emailLocale) }}
- {{ 'This link is valid until' | trans }} {{ app['date-formatter'].getDate(expiration) }} {{ app['date-formatter'].getTime(expiration) }} + {{ 'This link is valid until' | trans({}, "messages", emailLocale) }} {{ app['date-formatter'].getDate(expiration) }} {{ app['date-formatter'].getTime(expiration) }}
- {{ 'Le contenu de cet email est confidentiel, ne le divulguez pas.' | trans }} + {{ 'Le contenu de cet email est confidentiel, ne le divulguez pas.' | trans({}, "messages", emailLocale) }}
@@ -131,13 +131,13 @@ - {{ 'Message automatique de Phraseanet' | trans }}
+ {{ 'Message automatique de Phraseanet' | trans({}, "messages", emailLocale) }}
{% set link %} {{ phraseanetTitle }} {% endset %} - {% trans with {'%link%' : link} %}Pour gérer l'envoi d'email automatique, connectez-vous à %link%{% endtrans %} + {% trans with {'%link%' : link} from 'messages' into emailLocale %}Pour gérer l'envoi d'email automatique, connectez-vous à %link%{% endtrans %}