diff --git a/Classes/Controller/MailController.php b/Classes/Controller/MailController.php index 711d2f9968b4c3e871f8fc7088e5880b751b3f6a..d40e911d6274ff995fc56d843f792a96905296b9 100644 --- a/Classes/Controller/MailController.php +++ b/Classes/Controller/MailController.php @@ -143,16 +143,44 @@ class MailController extends ActionController { } } - $this->view->assign( - 'subjectLeft', $templateLeft !== NULL ? $templateLeft->getSubject() : - $registerArray[$selectedExtension][$selectedTemplate]['subjects'][$selectedLanguageLeft] - ); + $subject = $registerArray[$selectedExtension][$selectedTemplate]['subject']; + if (is_array($subject)) { + $this->view->assign( + 'subjectLeft', $templateLeft !== NULL ? $templateLeft->getSubject() : + $registerArray[$selectedExtension][$selectedTemplate]['subject'][$selectedLanguageLeft] + ); - $this->view->assign( - 'subjectRight', $templateRight !== NULL ? $templateRight->getSubject() : - $registerArray[$selectedExtension][$selectedTemplate]['subjects'][$selectedLanguageRight] - ); + $this->view->assign( + 'subjectRight', $templateRight !== NULL ? $templateRight->getSubject() : + $registerArray[$selectedExtension][$selectedTemplate]['subject'][$selectedLanguageRight] + ); + } else { + # @todo select languages to get specific independent translation + $this->view->assign( + 'subjectLeft', $templateLeft !== NULL ? $templateLeft->getSubject() : + LocalizationUtility::translate( + $subject, $selectedExtension + ) + ); + + $this->view->assign( + 'subjectRight', $templateRight !== NULL ? $templateRight->getSubject() : + LocalizationUtility::translate( + $subject, $selectedExtension + ) + ); + } + + $templateDescription = $registerArray[$selectedExtension][$selectedTemplate]['description']; + if (is_array($templateDescription)) { + $templateDescription = $templateDescription[$selectedLanguageLeft]; + } else { + $templateDescription = LocalizationUtility::translate( + $templateDescription, $selectedExtension + ); + } + $this->view->assign('templateDescription', $templateDescription); $this->view->assign('selectedTemplate', $selectedTemplateArray); $this->view->assign('selectedTemplateKey', $selectedTemplate); $this->view->assign('selectedExtensionKey', $selectedExtension); diff --git a/Classes/Service/MailTemplateService.php b/Classes/Service/MailTemplateService.php index c3868fd43c3e3f304abfa543172a2cea79d11881..190cb767d430149029c0a7028e3856c61dd19598 100644 --- a/Classes/Service/MailTemplateService.php +++ b/Classes/Service/MailTemplateService.php @@ -197,15 +197,18 @@ class MailTemplateService { /** * register a template with sg_mail * + * description and subject can now be an array i.e. with elements such as 'en' => 'english description' + * or an translation string used in locallang.xml + * * @param string $extension * @param string $templateName * @param string $templatePath - * @param string $description + * @param mixed $description * @param array $markers - * @param array $subjects + * @param mixed $subject */ public static function registerTemplate( - $extension, $templateName, $templatePath, $description, array $markers, array $subjects + $extension, $templateName, $templatePath, $description, array $markers, $subject ) { MailTemplateService::$registerArray[$extension][$templateName] = [ 'templatePath' => $templatePath, @@ -213,7 +216,7 @@ class MailTemplateService { 'marker' => $markers, 'extension' => $extension, 'templateName' => $templateName, - 'subjects' => $subjects + 'subject' => $subject ]; } @@ -307,7 +310,16 @@ class MailTemplateService { $subject = $template->getSubject(); } else { $emailView->setTemplateSource($defaultTemplateContent); - $subject = self::$registerArray[$this->extensionKey][$this->templateName]['subjects'][$this->language]; + + $subject = self::$registerArray[$this->extensionKey][$this->templateName]['subject']; + if (is_array($subject)) { + $subject = self::$registerArray[$this->extensionKey][$this->templateName]['subject'][$this->language]; + } else { + $subject = LocalizationUtility::translate( + self::$registerArray[$this->extensionKey][$this->templateName]['subject'], + $this->extensionKey + ); + } } $this->mailMessage->setSubject($subject); diff --git a/Resources/Private/Templates/Mail/Index.html b/Resources/Private/Templates/Mail/Index.html index 23bf37b11c2c07941a26ac2f857375e949a12dac..fd54c5d644069128f32c885adba673b1a6a6e1aa 100644 --- a/Resources/Private/Templates/Mail/Index.html +++ b/Resources/Private/Templates/Mail/Index.html @@ -8,7 +8,7 @@ <f:section name="main"> <f:flashMessages renderMode="div" /> <div class="col-md-12"> - <p>{selectedTemplate.description}</p> + <p>{templateDescription}</p> </div> <div class="col-md-12"> <table class="table table-hover">