function i18n_user_mail_alter in Internationalization 7
Implements hook_mail_alter().
File
- i18n_user/
i18n_user.module, line 10 - User mail translation module.
Code
function i18n_user_mail_alter(&$message) {
if ($message['module'] == 'user') {
$message['language'] = language_default();
if (isset($message['params']['account'])) {
$user_preferred = user_preferred_language($message['params']['account']);
if (isset($user_preferred)) {
$message['language'] = $user_preferred;
}
}
$language = isset($message['language']) ? $message['language'] : language_default();
$variables = array(
'user' => $message['params']['account'],
);
$key = $message['key'];
$components = array(
'subject',
'body',
);
foreach ($components as $component) {
$text = i18n_variable_get('user_mail_' . $key . '_' . $component, $language->language, FALSE);
if ($text) {
$text = token_replace($text, $variables, array(
'language' => $language,
'callback' => 'i18n_user_user_mail_tokens',
'sanitize' => FALSE,
));
switch ($component) {
case 'subject':
$message[$component] = $text;
break;
case 'body':
$message[$component] = array(
$text,
);
break;
}
}
}
}
}