function install_select_language_form

Form constructor for the language selection form.

Parameters

array $files: (optional) An associative array of file URIs keyed by language code as returned by file_scan_directory(). Defaults to all standard languages.

See also

file_scan_directory()

Related topics

1 string reference to 'install_select_language_form'
install_select_language in drupal/core/includes/install.core.inc
Selects which language to use during installation.

File

drupal/core/includes/install.core.inc, line 1495
API functions for installing Drupal.

Code

function install_select_language_form($form, &$form_state, $files = array()) {
  include_once __DIR__ . '/../modules/language/language.module';
  include_once __DIR__ . '/../modules/language/language.negotiation.inc';
  $standard_languages = LanguageManager::getStandardLanguageList();
  $select_options = array();
  $browser_options = array();

  // Build a select list with language names in native language for the user
  // to choose from. And build a list of available languages for the browser
  // to select the language default from.
  if (count($files)) {

    // Select lists based on available language files.
    foreach ($files as $langcode => $uri) {
      $select_options[$langcode] = isset($standard_languages[$langcode]) ? $standard_languages[$langcode][1] : $langcode;
      $browser_options[$langcode] = new Language(array(
        'langcode' => $langcode,
      ));
    }
  }
  else {

    // Select lists based on all standard languages.
    foreach ($standard_languages as $langcode => $language_names) {
      $select_options[$langcode] = $language_names[1];
      $browser_options[$langcode] = new Language(array(
        'langcode' => $langcode,
      ));
    }
  }
  $browser_langcode = language_from_browser($browser_options);
  $form['langcode'] = array(
    '#type' => 'select',
    '#title' => st('Choose language'),
    '#title_display' => 'invisible',
    '#options' => $select_options,
    // Use the browser detected language as default or English if nothing found.
    '#default_value' => !empty($browser_langcode) ? $browser_langcode : 'en',
  );
  if (empty($files)) {
    $form['help'] = array(
      '#markup' => '<p>Translations will be downloaded from the <a href="http://localize.drupal.org">Drupal Translation website</a>. ' . 'If you do not want this, select <em>English</em> and continue the installation. For more information, see the <a href="http://drupal.org/documentation/install">online handbook</a>.</p>',
    );
  }
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => st('Save and continue'),
  );
  return $form;
}