Skip to content

Commit

Permalink
feat: Fix implementing translations in latte templates
Browse files Browse the repository at this point in the history
  • Loading branch information
KminekMatej committed Sep 7, 2024
1 parent bf8db7b commit 291e868
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/module/core/service/MailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Contributte\Translation\Translator;
use Latte\Engine;
use Latte\Essential\TranslatorExtension;
use Nette\Mail\Mailer;
use Nette\Mail\Message;
use Nette\Mail\SendException;
Expand Down Expand Up @@ -85,7 +86,10 @@ public function mailInvitation(string $nameTo, string $emailTo, string $nameFrom

$latte = new Engine();

$latte->addFilter('translate', fn($message, $parameters): string => $this->translator->translate($message, $parameters));
$translatorExtension = new TranslatorExtension(
$this->translator->translate(...),
);
$latte->addExtension($translatorExtension);

$subject = $this->translator->translate("mail.invitation.subject");

Expand Down

0 comments on commit 291e868

Please sign in to comment.