Created
February 8, 2016 06:37
-
-
Save delta-9/084b501b365bd1b95d8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Remember original language before this operation. | |
$original_language = \Drupal::configFactory()->getLanguage(); | |
$language = language_load($account->getPreferredLangcode()); | |
// Set the languag without saving, this is actually only for the current script execution: | |
\Drupal::configFactory()->setLanguage($language); | |
// Get the user.mail config object normally, but for the language we just set :) | |
$mail_config = \Drupal::config('user.mail'); | |
// Now send email based on $mail_config which is in the proper language. | |
//... | |
// Set back the language to the prior value. | |
\Drupal::configFactory()->setLanguage($original_language); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment