I encountered a problem with the translation symfony today.
Sent by SwiftMailer, emails are created in personal service.
case 1: function sendWelcomeEmailMessage is called in a Controller, simply when a new user is registered, the trans key 'registration.email.welcome.subject' is well translated
case 2: function sendReflationEmailMessage is called in a symfony2 Command, but here, the key 'registration.email.welcome.subject' (same key for test) is not translated...
Someone has an idea ?
/**
* @param UserInterface $user
*/
public function sendWelcomeEmailMessage(UserInterface $user)
{
$params = $this->parameters['registration']['welcome'];
$rendered = $this->templating->render(
$params['template'], [
'user' => $user
]
);
$subject = $this->translator->trans('registration.email.welcome.subject');
$this->sendEmailMessage($rendered, $subject, $params['from_email'], $user->getEmail());
}
/**
* @param UserInterface $user
*/
public function sendReflationEmailMessage(UserInterface $user)
{
$params = $this->parameters['registration']['reflation'];
$rendered = $this->templating->render(
$params['template'], [
'user' => $user
]
);
$subject = $this->translator->trans('registration.email.welcome.subject'); // Same trans key, only for test
$this->sendEmailMessage($rendered, $subject, $params['from_email'], $user->getEmail());
}