Same name and namespace in other branches
  1. 4.6.x modules/locale.module \locale_user()
  2. 4.7.x modules/locale.module \locale_user()
  3. 6.x modules/locale/locale.module \locale_user()

Implementation of hook_user().

File

modules/locale/locale.module, line 133
Enables administrators to manage the site interface languages.

Code

function locale_user($type, $edit, &$user, $category = NULL) {
  $languages = locale_supported_languages();
  if ($type == 'form' && $category == 'account' && count($languages['name']) > 1) {
    if ($user->language == '') {
      $user->language = key($languages['name']);
    }
    foreach (array_map('t', $languages['name']) as $key => $value) {
      $languages_name[check_plain($key)] = check_plain($value);
    }
    $form['locale'] = array(
      '#type' => 'fieldset',
      '#title' => t('Interface language settings'),
      '#weight' => 1,
    );
    $form['locale']['language'] = array(
      '#type' => 'radios',
      '#title' => t('Language'),
      '#default_value' => check_plain($user->language),
      '#options' => $languages_name,
      '#description' => t('Selecting a different locale will change the interface language of the site.'),
    );
    return $form;
  }
}