function user_preferred_language

Get the language object preferred by the user. This user preference can be set on the user account editing page, and is only available if there are more than one languages enabled on the site. If the user did not choose a preferred language, or is the anonymous user, the $default value, or if it is not set, the site default language will be returned.

Parameters

$account: User account to look up language for.

$default: Optional default language object to return if the account has no valid language.

5 calls to user_preferred_language()
contact_personal_form_submit in drupal/modules/contact/contact.pages.inc
Form submission handler for contact_personal_form().
locale_language_selector_form in drupal/modules/locale/locale.module
Form builder callback to display language selection widget.
system_send_email_action in drupal/modules/system/system.module
Sends an e-mail message.
_update_cron_notify in drupal/modules/update/update.fetch.inc
Performs any notifications that should be done once cron fetches new data.
_user_mail_notify in drupal/modules/user/user.module
Conditionally create and send a notification email when a certain operation happens on the given user account.

File

drupal/modules/user/user.module, line 3586
Enables the user registration and login system.

Code

function user_preferred_language($account, $default = NULL) {
  $language_list = language_list();
  if (!empty($account->language) && isset($language_list[$account->language])) {
    return $language_list[$account->language];
  }
  else {
    return $default ? $default : language_default();
  }
}