function i18n_contact_mail_alter in Internationalization 7
Implements hook_mail_alter().
File
- i18n_contact/
i18n_contact.module, line 75 - Internationalization (i18n) submodule: Multilingual contact forms
Code
function i18n_contact_mail_alter(&$message) {
if (in_array($message['id'], array(
'contact_page_mail',
'contact_page_copy',
'contact_page_autoreply',
))) {
// Alter the first part of the subject of emails going out if they need
// translation.
$contact = i18n_string_object_translate('contact_category', $message['params']['category'], array(
'langcode' => $message['language']->language,
));
$message['subject'] = t('[!category] !subject', array(
'!category' => $contact['category'],
'!subject' => $message['params']['subject'],
), array(
'langcode' => $message['language']->language,
));
if ($message['id'] == 'contact_page_autoreply') {
// Overwrite the whole message body. Maybe this is not entirely responsible
// (it might overwrite other existing items altered in by others),
// but unfortunately Drupal core cotact module does not make its item
// identifiable easily.
$message['body'] = array(
$contact['reply'],
);
}
}
}