function language_from_user

Identify language from the user preferences.

Parameters

$languages: An array of valid language objects.

Return value

A valid language code on success, FALSE otherwise.

2 string references to 'language_from_user'
language_language_negotiation_info in drupal/core/modules/language/language.module
Implements hook_language_negotiation_info().
locale_update_8007 in drupal/core/modules/locale/locale.install
Convert language_negotiation_* variables to use the new callbacks.

File

drupal/core/modules/language/language.negotiation.inc, line 195
Language negotiation functions.

Code

function language_from_user($languages) {

  // User preference (only for authenticated users).
  global $user;
  if ($user->uid && !empty($user->preferred_langcode) && isset($languages[$user->preferred_langcode])) {
    return $user->preferred_langcode;
  }

  // No language preference from the user.
  return FALSE;
}