I'm sending out custom emails based on certain events to my users. These users have chosen a certain prefered locale in their profile settings and I'd like for those emails to be in that locale instead of in the locale of the control panel at the time of triggering the events.
So what I'm looking for is a way to set the relevant locale before rendering the email template with twig but I cant seem to find a way.
$mailer = craft()->email; $mailToBeSent = new EmailModel(); craft()->templates->setTemplatesPath(CRAFT_TEMPLATES_PATH); $mailToBeSent->toEmail = 'firstname.lastname@example.org'; $mailToBeSent->subject = $subject; $content = craft()->templates->render( '_emails/notification', [ 'userInfo' => $this->generateUserInfo($newUser), ] ); $mailToBeSent->htmlBody = $content; $mailer->sendEmail($mailToBeSent);
Let me know more information is needed or if something is unclear.