diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2020-04-16 10:06:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-16 10:06:55 +0200 |
commit | fc2e17d33f8087dd4fc7e8736d4445fda9a01e98 (patch) | |
tree | 95aa31f3934bcb87511a89c855c3375128807181 /lib | |
parent | 1f2df2f6bc025521800763bb67d50608a138f73a (diff) | |
parent | bb4dedb0156727ebd88a3f922fedc78436d7b701 (diff) | |
download | nextcloud-server-fc2e17d33f8087dd4fc7e8736d4445fda9a01e98.tar.gz nextcloud-server-fc2e17d33f8087dd4fc7e8736d4445fda9a01e98.zip |
Merge pull request #20246 from nextcloud/fix/untranslated_mail_footer
Provide the proper language to the mailer
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Mail/EMailTemplate.php | 22 | ||||
-rw-r--r-- | lib/private/Mail/Mailer.php | 9 | ||||
-rw-r--r-- | lib/private/Server.php | 3 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 4 | ||||
-rw-r--r-- | lib/private/legacy/OC_Defaults.php | 6 | ||||
-rw-r--r-- | lib/public/Defaults.php | 4 | ||||
-rw-r--r-- | lib/public/Mail/IEMailTemplate.php | 3 |
7 files changed, 26 insertions, 25 deletions
diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php index 9e2f099259c..3bb5b299f4e 100644 --- a/lib/private/Mail/EMailTemplate.php +++ b/lib/private/Mail/EMailTemplate.php @@ -35,8 +35,8 @@ declare(strict_types=1); namespace OC\Mail; use OCP\Defaults; -use OCP\IL10N; use OCP\IURLGenerator; +use OCP\L10N\IFactory; use OCP\Mail\IEMailTemplate; /** @@ -52,8 +52,8 @@ class EMailTemplate implements IEMailTemplate { protected $themingDefaults; /** @var IURLGenerator */ protected $urlGenerator; - /** @var IL10N */ - protected $l10n; + /** @var IFactory */ + protected $l10nFactory; /** @var string */ protected $emailId; /** @var array */ @@ -350,21 +350,14 @@ EOF; </table> EOF; - /** - * @param Defaults $themingDefaults - * @param IURLGenerator $urlGenerator - * @param IL10N $l10n - * @param string $emailId - * @param array $data - */ public function __construct(Defaults $themingDefaults, IURLGenerator $urlGenerator, - IL10N $l10n, + IFactory $l10nFactory, $emailId, array $data) { $this->themingDefaults = $themingDefaults; $this->urlGenerator = $urlGenerator; - $this->l10n = $l10n; + $this->l10nFactory = $l10nFactory; $this->htmlBody .= $this->head; $this->emailId = $emailId; $this->data = $data; @@ -605,9 +598,10 @@ EOF; * * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used */ - public function addFooter(string $text = '') { + public function addFooter(string $text = '', ?string $lang = null) { if ($text === '') { - $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.'); + $l10n = $this->l10nFactory->get('lib', $lang); + $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan($lang) . '<br>' . $l10n->t('This is an automatically sent email, please do not reply.'); } if ($this->footerAdded) { diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php index 57778e263d7..3ef77e6239c 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -41,6 +41,7 @@ use OCP\IConfig; use OCP\IL10N; use OCP\ILogger; use OCP\IURLGenerator; +use OCP\L10N\IFactory; use OCP\Mail\IAttachment; use OCP\Mail\IEMailTemplate; use OCP\Mail\IMailer; @@ -80,6 +81,8 @@ class Mailer implements IMailer { private $l10n; /** @var IEventDispatcher */ private $dispatcher; + /** @var IFactory */ + private $l10nFactory; /** * @param IConfig $config @@ -94,13 +97,15 @@ class Mailer implements IMailer { Defaults $defaults, IURLGenerator $urlGenerator, IL10N $l10n, - IEventDispatcher $dispatcher) { + IEventDispatcher $dispatcher, + IFactory $l10nFactory) { $this->config = $config; $this->logger = $logger; $this->defaults = $defaults; $this->urlGenerator = $urlGenerator; $this->l10n = $l10n; $this->dispatcher = $dispatcher; + $this->l10nFactory = $l10nFactory; } /** @@ -158,7 +163,7 @@ class Mailer implements IMailer { return new EMailTemplate( $this->defaults, $this->urlGenerator, - $this->l10n, + $this->l10nFactory, $emailId, $data ); diff --git a/lib/private/Server.php b/lib/private/Server.php index a7432342a27..cf4f8cc097b 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -995,7 +995,8 @@ class Server extends ServerContainer implements IServerContainer { $c->query(Defaults::class), $c->getURLGenerator(), $c->getL10N('lib'), - $c->query(IEventDispatcher::class) + $c->query(IEventDispatcher::class), + $c->getL10NFactory() ); }); $this->registerDeprecatedAlias('Mailer', IMailer::class); diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 78d79b5c4da..becf29e4cc7 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -891,9 +891,9 @@ class Manager implements IManager { $initiatorEmail = $initiatorUser->getEMailAddress(); if ($initiatorEmail !== null) { $message->setReplyTo([$initiatorEmail => $initiatorDisplayName]); - $emailTemplate->addFooter($instanceName . ($this->defaults->getSlogan() !== '' ? ' - ' . $this->defaults->getSlogan() : '')); + $emailTemplate->addFooter($instanceName . ($this->defaults->getSlogan($l->getLanguageCode()) !== '' ? ' - ' . $this->defaults->getSlogan($l->getLanguageCode()) : '')); } else { - $emailTemplate->addFooter(); + $emailTemplate->addFooter('', $l->getLanguageCode()); } $message->useTemplate($emailTemplate); diff --git a/lib/private/legacy/OC_Defaults.php b/lib/private/legacy/OC_Defaults.php index f90cae61bd7..3b40b815112 100644 --- a/lib/private/legacy/OC_Defaults.php +++ b/lib/private/legacy/OC_Defaults.php @@ -214,12 +214,12 @@ class OC_Defaults { * Returns slogan * @return string slogan */ - public function getSlogan() { + public function getSlogan(?string $lang = null) { if ($this->themeExist('getSlogan')) { - return $this->theme->getSlogan(); + return $this->theme->getSlogan($lang); } else { if ($this->defaultSlogan === null) { - $l10n = \OC::$server->getL10N('lib'); + $l10n = \OC::$server->getL10N('lib', $lang); $this->defaultSlogan = $l10n->t('a safe home for all your data'); } return $this->defaultSlogan; diff --git a/lib/public/Defaults.php b/lib/public/Defaults.php index af7a1567571..afb606febf6 100644 --- a/lib/public/Defaults.php +++ b/lib/public/Defaults.php @@ -137,8 +137,8 @@ class Defaults { * @return string * @since 6.0.0 */ - public function getSlogan() { - return $this->defaults->getSlogan(); + public function getSlogan(?string $lang = null) { + return $this->defaults->getSlogan($lang); } /** diff --git a/lib/public/Mail/IEMailTemplate.php b/lib/public/Mail/IEMailTemplate.php index 8950f18e31c..70046d5c508 100644 --- a/lib/public/Mail/IEMailTemplate.php +++ b/lib/public/Mail/IEMailTemplate.php @@ -140,10 +140,11 @@ interface IEMailTemplate { * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email * * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used + * @param string $lang Optional language to set the default footer in * * @since 12.0.0 */ - public function addFooter(string $text = ''); + public function addFooter(string $text = '', ?string $lang = null); /** * Returns the rendered email subject as string |