1 locale.module locale_form_alter(&$form, &$form_state, $form_id)

Implements hook_form_alter().

Adds language fields to user forms.

File

core/modules/locale/locale.module, line 197
Add language handling functionality and enables the translation of the user interface to languages other than English.

Code

function locale_form_alter(&$form, &$form_state, $form_id) {
  // Only alter user forms if there is more than one language.
  if (language_multilingual()) {
    // Display language selector when either creating a user on the admin
    // interface or editing a user account.
    if ($form_id == 'user_register_form' || $form_id == 'user_profile_form') {
      $selector = locale_language_selector_form($form['#user']);
      $selector['locale']['#type'] = 'container';
      $form['region_language'] += $selector;
      if ($form_id == 'user_register_form') {
        $form['region_language']['locale']['#access'] = user_access('administer users');
      }
    }
  }
}