diff --git a/core/includes/mail.inc b/core/includes/mail.inc
index 1be3c38..adf9096 100644
--- a/core/includes/mail.inc
+++ b/core/includes/mail.inc
@@ -27,12 +27,13 @@ define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER
  * Finding out what language to send the e-mail with needs some consideration.
  * If you send e-mail to a user, her preferred language should be fine, so
  * use user_preferred_language(). If you send email based on form values
+ * use user_preferred_langcode(). If you send email based on form values
  * filled on the page, there are two additional choices if you are not
  * sending the e-mail to a user on the site. You can either use the language
- * used to generate the page ($language global variable) or the site default
- * language. See language_default(). The former is good if sending e-mail to
- * the person filling the form, the later is good if you send e-mail to an
- * address previously set up (like contact addresses in a contact form).
+ * used to generate the page or the site default language. See
+ * language_default(). The former is good if sending e-mail to the person
+ * filling the form, the later is good if you send e-mail to an address
+ * previously set up (like contact addresses in a contact form).
  *
  * Taking care of always using the proper language is even more important
  * when sending e-mails in a row to multiple users. Hook_mail() abstracts
@@ -47,13 +48,13 @@ define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER
  *     foreach ($accounts as $account) {
  *       $params['account'] = $account;
  *       // example_mail() will be called based on the first drupal_mail() parameter.
- *       drupal_mail('example', 'notice', $account->mail, user_preferred_language($account), $params);
+ *       drupal_mail('example', 'notice', $account->mail, user_preferred_langcode($account), $params);
  *     }
  *   }
  *
  *   function example_mail($key, &$message, $params) {
  *     $data['user'] = $params['account'];
- *     $options['langcode'] = $message['language'];
+ *     $options = array('langcode' => $message['langcode']);
  *     user_mail_tokens($variables, $data, $options);
  *     switch($key) {
  *       case 'notice':
@@ -63,9 +64,8 @@ define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER
  *           $message['send'] = FALSE;
  *           break;
  *         }
- *         $langcode = $message['language']->langcode;
- *         $message['subject'] = t('Notification from !site', $variables, array('langcode' => $langcode));
- *         $message['body'][] = t("Dear !username\n\nThere is new content available on the site.", $variables, array('langcode' => $langcode));
+ *         $message['subject'] = t('Notification from !site', $variables, $options);
+ *         $message['body'][] = t("Dear !username\n\nThere is new content available on the site.", $variables, $options);
  *         break;
  *     }
  *   }
@@ -77,7 +77,7 @@ define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER
  * @code
  *   $params = array('current_conditions' => $data);
  *   $to = 'user@example.com';
- *   $message = drupal_mail('example', 'notice', $to, $language, $params, FALSE);
+ *   $message = drupal_mail('example', 'notice', $to, $langcode, $params, FALSE);
  *   // Only add to the spool if sending was not canceled.
  *   if ($message['send']) {
  *     example_spool_message($message);
@@ -98,10 +98,10 @@ define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER
  *   - user@example.com, anotheruser@example.com
  *   - User <user@example.com>
  *   - User <user@example.com>, Another User <anotheruser@example.com>
- * @param $language
- *   Language object to use to compose the e-mail.
+ * @param $langcode
+ *   Language code to use to compose the e-mail.
  * @param $params
- *   Optional parameters to build the e-mail.
+ *   (optional) parameters to build the e-mail.
  * @param $from
  *   Sets From to this value, if given.
  * @param $send
@@ -117,7 +117,7 @@ define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER
  *   written to the watchdog. (Success means nothing more than the message being
  *   accepted at php-level, which still doesn't guarantee it to be delivered.)
  */
-function drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE) {
+function drupal_mail($module, $key, $to, $langcode, $params = array(), $from = NULL, $send = TRUE) {
   $site_mail = config('system.site')->get('mail');
   if (empty($site_mail)) {
     $site_mail = ini_get('sendmail_from');
@@ -131,7 +131,7 @@ function drupal_mail($module, $key, $to, $language, $params = array(), $from = N
     'key'      => $key,
     'to'       => $to,
     'from'     => isset($from) ? $from : $default_from,
-    'language' => $language,
+    'langcode' => $langcode,
     'params'   => $params,
     'send'     => TRUE,
     'subject'  => '',
diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module
index 1ba70b9..985abbd 100644
--- a/core/modules/contact/contact.module
+++ b/core/modules/contact/contact.module
@@ -168,7 +168,7 @@ function contact_load($cid) {
  * Implements hook_mail().
  */
 function contact_mail($key, &$message, $params) {
-  $language = $message['language'];
+  $language = language_load($message['langcode']);
   $variables = array(
     '!site-name' => config('system.site')->get('name'),
     '!subject' => $params['subject'],
diff --git a/core/modules/contact/contact.pages.inc b/core/modules/contact/contact.pages.inc
index 92d73bc..2c6efd5 100644
--- a/core/modules/contact/contact.pages.inc
+++ b/core/modules/contact/contact.pages.inc
@@ -173,12 +173,12 @@ function contact_site_form_submit($form, &$form_state) {
 
   // If the user requests it, send a copy using the current language.
   if ($values['copy']) {
-    drupal_mail('contact', 'page_copy', $from, $language_interface, $values, $from);
+     drupal_mail('contact', 'page_copy', $from, $language_interface->langcode, $values, $from);
   }
 
   // Send an auto-reply if necessary using the current language.
   if ($values['category']['reply']) {
-    drupal_mail('contact', 'page_autoreply', $from, $language_interface, $values, $to);
+    drupal_mail('contact', 'page_autoreply', $from, $language_interface->langcode, $values, $to);
   }
 
   flood_register_event('contact', config('contact.settings')->get('flood.interval'));
@@ -310,11 +310,11 @@ function contact_personal_form_submit($form, &$form_state) {
   $from = $values['sender']->mail;
 
   // Send the e-mail in the requested user language.
-  drupal_mail('contact', 'user_mail', $to, user_preferred_language($values['recipient']), $values, $from);
+  drupal_mail('contact', 'user_mail', $to, user_preferred_langcode($values['recipient']), $values, $from);
 
   // Send a copy if requested, using current page language.
   if ($values['copy']) {
-    drupal_mail('contact', 'user_copy', $from, $language_interface, $values, $from);
+    drupal_mail('contact', 'user_copy', $from, $language_interface->langcode, $values, $from);
   }
 
   flood_register_event('contact', config('contact.settings')->get('flood.interval'));
diff --git a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php
index d75b593..83ab14b 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php
@@ -52,7 +52,7 @@ class MailTest extends WebTestBase implements MailInterface {
     $language_interface = language(LANGUAGE_TYPE_INTERFACE);
 
     // Use MailTestCase for sending a message.
-    $message = drupal_mail('simpletest', 'mail_test', 'testing@example.com', $language_interface);
+    $message = drupal_mail('simpletest', 'mail_test', 'testing@example.com', $language_interface->langcode);
 
     // Assert whether the message was sent through the send function.
     $this->assertEqual(self::$sent_message['to'], 'testing@example.com', t('Pluggable mail system is extendable.'));
@@ -64,13 +64,13 @@ class MailTest extends WebTestBase implements MailInterface {
    * @see simpletest_mail_alter()
    */
   public function testCancelMessage() {
-    global $language;
+  $language_interface = language(LANGUAGE_TYPE_INTERFACE);
 
     // Reset the class variable holding a copy of the last sent message.
     self::$sent_message = NULL;
 
     // Send a test message that simpletest_mail_alter should cancel.
-    $message = drupal_mail('simpletest', 'cancel_test', 'cancel@example.com', $language);
+    $message = drupal_mail('simpletest', 'cancel_test', 'cancel@example.com', $language_interface->langcode);
 
     // Assert that the message was not actually sent.
     $this->assertNull(self::$sent_message, 'Message was canceled.');
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index 14f3630..41718e4 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -1945,7 +1945,7 @@ function hook_watchdog(array $log_entry) {
     '@message'       => strip_tags($log_entry['message']),
   ));
 
-  drupal_mail('emaillog', 'entry', $to, $language_interface, $params);
+   drupal_mail('emaillog', 'entry', $to, $language_interface->langcode, $params);
 }
 
 /**
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index ad4c5dd..74994db 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -3660,14 +3660,14 @@ function system_send_email_action($entity, $context) {
   // language.
   $recipient_account = user_load_by_mail($recipient);
   if ($recipient_account) {
-    $language = user_preferred_language($recipient_account);
+   $langcode = user_preferred_langcode($recipient_account);
   }
   else {
-    $language = language_default();
+    $langcode = language_default()->langcode;
   }
   $params = array('context' => $context);
 
-  if (drupal_mail('system', 'action_send_email', $recipient, $language, $params)) {
+  if (drupal_mail('system', 'action_send_email', $recipient, $langcode, $params)) {
     watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient));
   }
   else {
diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc
index 76eeb54..ff1e228 100644
--- a/core/modules/update/update.fetch.inc
+++ b/core/modules/update/update.fetch.inc
@@ -366,15 +366,15 @@ function _update_cron_notify() {
   if (!empty($params)) {
     $notify_list = $update_config->get('notification.emails');
     if (!empty($notify_list)) {
-      $default_language = language_default();
+     $default_langcode = language_default()->langcode;
       foreach ($notify_list as $target) {
         if ($target_user = user_load_by_mail($target)) {
           $target_language = user_preferred_language($target_user);
         }
         else {
-          $target_language = $default_language;
+         $target_langcode = $default_langcode;
         }
-        $message = drupal_mail('update', 'status_notify', $target, $target_language, $params);
+        $message = drupal_mail('update', 'status_notify', $target, $target_langcode, $params);
         // Track when the last mail was successfully sent to avoid sending
         // too many e-mails.
         if ($message['result']) {
diff --git a/core/modules/update/update.module b/core/modules/update/update.module
index bee906f..88c2bf9 100644
--- a/core/modules/update/update.module
+++ b/core/modules/update/update.module
@@ -510,11 +510,10 @@ function _update_get_cached_available_releases() {
  * @see _update_message_text()
  */
 function update_mail($key, &$message, $params) {
-  $language = $message['language'];
-  $langcode = $language->langcode;
+  $langcode = $message['langcode'];
   $message['subject'] .= t('New release(s) available for !site_name', array('!site_name' => config('system.site')->get('name')), array('langcode' => $langcode));
   foreach ($params as $msg_type => $msg_reason) {
-    $message['body'][] = _update_message_text($msg_type, $msg_reason, FALSE, $language);
+    $message['body'][] = _update_message_text($msg_type, $msg_reason, FALSE, $langcode);
   }
   $message['body'][] = t('See the available updates page for more information:', array(), array('langcode' => $langcode)) . "\n" . url('admin/reports/updates', array('absolute' => TRUE, 'language' => $language));
   if (update_manager_access()) {
@@ -544,14 +543,13 @@ function update_mail($key, &$message, $params) {
  * @param $report_link
  *   (optional) Boolean that controls if a link to the updates report should be
  *   added. Defaults to FALSE.
- * @param $language
- *   (optional) A language object to use. Defaults to NULL.
+ * @param $langcode
+ *   (optional) A language code to use. Defaults to NULL.
  *
  * @return
  *   The properly translated error message for the given key.
  */
-function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $language = NULL) {
-  $langcode = isset($language) ? $language->langcode : NULL;
+function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $langcode = NULL) {
   $text = '';
   switch ($msg_reason) {
     case UPDATE_NOT_SECURE:
@@ -603,6 +601,12 @@ function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $lan
       break;
   }
 
+  if (!empty($langcode)) {
+    $language = language_load(langcode);
+  }
+  else {
+   $language = NULL;
+  }
   if ($report_link) {
     if (update_manager_access()) {
       $text .= ' ' . t('See the <a href="@available_updates">available updates</a> page for more information and to install your missing updates.', array('@available_updates' => url('admin/reports/updates/update', array('language' => $language))), array('langcode' => $langcode));
diff --git a/core/modules/user/lib/Drupal/user/AccountFormController.php b/core/modules/user/lib/Drupal/user/AccountFormController.php
index 3a3ecaa..20871a4 100644
--- a/core/modules/user/lib/Drupal/user/AccountFormController.php
+++ b/core/modules/user/lib/Drupal/user/AccountFormController.php
@@ -204,7 +204,7 @@ abstract class AccountFormController extends EntityFormController {
 
     $form['#validate'][] = 'user_validate_picture';
 
-    $user_preferred_language = $register ? $language_interface : user_preferred_language($account);
+    $user_preferred_langcode = $register ? $language_interface->langcode : user_preferred_langcode($account);
 
     $user_preferred_admin_language = $register ? $language_interface : user_preferred_language($account, 'admin');
 
@@ -223,7 +223,7 @@ abstract class AccountFormController extends EntityFormController {
       '#type' => 'language_select',
       '#title' => t('Site language'),
       '#languages' => LANGUAGE_CONFIGURABLE,
-      '#default_value' => $user_preferred_language->langcode,
+      '#default_value' => $user_preferred_langcode,
       '#description' => $interface_language_is_default ? t("This account's preferred language for e-mails and site presentation.") : t("This account's preferred language for e-mails."),
     );
 
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index a526b20..25d2280 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -2121,19 +2121,33 @@ function user_build_content($account, $view_mode = 'full', $langcode = NULL) {
  * Implements hook_mail().
  */
 function user_mail($key, &$message, $params) {
-  $language = $message['language'];
+  $langcode = $message['langcode'];
   $variables = array('user' => $params['account']);
-  $message['subject'] .= _user_mail_text($key . '_subject', $language, $variables);
-  $message['body'][] = _user_mail_text($key . '_body', $language, $variables);
+  $message['subject'] .= _user_mail_text($key . '_subject', $langcode, $variables);
+  $message['body'][] = _user_mail_text($key . '_body', $langcode, $variables);
 }
 
 /**
  * Returns a mail string for a variable name.
  *
  * Used by user_mail() and the settings forms to retrieve strings.
+ *
+ * @param $key
+ *   Key of the variable name.
+ * @param $langcode
+ *   (optional) A language code to use to generate the e-mail text.
+ * @param $variables
+ *   (optional) An array of keyed objects. For simple replacement scenarios
+ *   'node', 'user', and others are common keys, with an accompanying node or
+ *   user object being the value. Some token types, like 'site', do not require
+ *   any explicit information from $variables and can be replaced even
+ *   if it is empty.
+ * @param $replace
+ *   (optional) option to sanitize the token replacement.
+ *
  */
-function _user_mail_text($key, $language = NULL, $variables = array(), $replace = TRUE) {
-  $langcode = isset($language) ? $language->langcode : NULL;
+function _user_mail_text($key, $langcode = NULL, $variables = array(), $replace = TRUE) {
+
 
   if ($admin_setting = variable_get('user_mail_' . $key, FALSE)) {
     // An admin setting overrides the default string.
@@ -2285,6 +2299,12 @@ Your account on [site:name] has been canceled.
   if ($replace) {
     // We do not sanitize the token replacement, since the output of this
     // replacement is intended for an e-mail message, not a web browser.
+     if (!empty($langcode)) {
+      $language = language_load($langcode);
+    }
+    else {
+      $language = NULL;
+    }
     return token_replace($text, $variables, array('langcode' => $langcode, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
   }
 
@@ -2955,10 +2975,10 @@ function theme_user_signature($variables) {
  *   Default to 'preferred_langcode' property.
  *   If set 'preferred_$type_langcode' is used.
  * @param $default
- *   Optional default language object to return if the account
+ *   Optional default language code to return if the account
  *   has no valid language.
  */
-function user_preferred_language($account, $type = NULL, $default = NULL) {
+function user_preferred_langcode($account, $type = NULL, $default = NULL) {
   $language_list = language_list();
   if (isset($type)) {
     $preferred_langcode = $account->{'preferred_' . $type . '_langcode'};
@@ -2967,10 +2987,10 @@ function user_preferred_language($account, $type = NULL, $default = NULL) {
     $preferred_langcode = $account->preferred_langcode;
   }
   if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) {
-    return $language_list[$preferred_langcode];
+    return $language_list[$account->preferred_langcode]->langcode;
   }
   else {
-    return $default ? $default : language_default();
+     return language_default()->langcode;
   }
 }
 
@@ -2997,20 +3017,23 @@ function user_preferred_language($account, $type = NULL, $default = NULL) {
  * @param $account
  *   The user object of the account being notified. Must contain at
  *   least the fields 'uid', 'name', and 'mail'.
- * @param $language
- *   Optional language to use for the notification, overriding account language.
+ * @param $langcode
+ *   Optional language code to use for the notification, overriding
+ *   account language.
  *
  * @return
  *   The return value from drupal_mail_system()->mail(), if ends up being
  *   called.
  */
-function _user_mail_notify($op, $account, $language = NULL) {
+function _user_mail_notify($op, $account, $langcode = NULL) {
   // By default, we always notify except for canceled and blocked.
   $notify = config('user.settings')->get('notify.' . $op);
   if ($notify || ($op != 'status_canceled' && $op != 'status_blocked')) {
     $params['account'] = $account;
-    $language = $language ? $language : user_preferred_language($account);
-    $mail = drupal_mail('user', $op, $account->mail, $language, $params);
+	if (empty($langcode)) {
+	      $langcode = user_preferred_langcode($account);
+	    }
+    $mail = drupal_mail('user', $op, $account->mail, $langcode, $params);
     if ($op == 'register_pending_approval') {
       // If a user registered requiring admin approval, notify the admin, too.
       // We use the site default language for this.
@@ -3018,7 +3041,7 @@ function _user_mail_notify($op, $account, $language = NULL) {
       if (empty($site_mail)) {
         $site_mail = ini_get('sendmail_from');
       }
-      drupal_mail('user', 'register_pending_approval_admin', $site_mail, language_default(), $params);
+      drupal_mail('user', 'register_pending_approval_admin', $site_mail, language_default()->langcode, $params);
     }
   }
   return empty($mail) ? NULL : $mail['result'];
diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc
index d26ca6d..9dd2cc9 100644
--- a/core/modules/user/user.pages.inc
+++ b/core/modules/user/user.pages.inc
@@ -81,7 +81,7 @@ function user_pass_submit($form, &$form_state) {
 
   $account = $form_state['values']['account'];
   // Mail one time login URL and instructions using current language.
-  $mail = _user_mail_notify('password_reset', $account, $language_interface);
+  $mail = _user_mail_notify('password_reset', $account, $language_interface->langcode);
   if (!empty($mail)) {
     watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => $account->name, '%email' => $account->mail));
     drupal_set_message(t('Further instructions have been sent to your e-mail address.'));
