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

Implements hook_form_alter().

Adds language fields to user forms.


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


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']);
      if ($form_id == 'user_register_form') {
        $selector['locale']['#access'] = user_access('administer users');
      $form += $selector;