Sending a custom email in the users prefered locale Usecase:

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. 



Relevant code

$mailer = craft()-&gt;email;
$mailToBeSent = new EmailModel();

craft()-&gt;templates-&gt;setTemplatesPath(CRAFT_TEMPLATES_PATH);
$mailToBeSent-&gt;toEmail = 'some.email@domain.com';

$mailToBeSent-&gt;subject = $subject;

$content = craft()-&gt;templates-&gt;render(
   '_emails/notification',
    [
        'userInfo' =&gt; $this-&gt;generateUserInfo($newUser),
    ]

);

$mailToBeSent-&gt;htmlBody = $content;
$mailer-&gt;sendEmail($mailToBeSent);




Let me know more information is needed or if something is unclear.
You can translate string in PHP and Twig via translate function

public static function t($message, $variables = array(), $source = null, $language = null, $category = 'craft')


Twig

{{ 'my string'|t() }}


PHP

Craft::t('my string');


So all you need to do is to wrap every string in your templates within the translate filter and pass the preferred local as an argument. For example 

{{ 'my latest news'|t([], null, currentUser.locale) }}


If no parameter is set, Craft will use craft()-&gt;getLanguage() by default so you can do the following as well

$tmpLocale = craft()-&gt;getLanguage();
$user = craft()-&gt;userSession-&gt;getUser();
craft()-&gt;setLanguage($user-&gt;locale);
$content = craft()-&gt;templates-&gt;render(
   '_emails/notification',
   [
       'userInfo' =&gt; $this-&gt;generateUserInfo($newUser),
   ]
); 
$craft-&gt;setLanguage($tmpLocale);