1 install.core.inc install_select_language_form($form, &$form_state, $files)

Form constructor for the language selection form.

Related topics

File

core/includes/install.core.inc, line 1409
API functions for installing Backdrop.

Code

function install_select_language_form($form, &$form_state, $files) {
  include_once BACKDROP_ROOT . '/core/includes/standard.inc';
  include_once BACKDROP_ROOT . '/core/includes/locale.inc';

  $standard_languages = standard_language_list();
  $select_options = array();
  $languages = array();

  foreach ($files as $file) {
    if (isset($standard_languages[$file->langcode])) {
      // Build a list of select list options based on files we found.
      $select_options[$file->langcode] = $standard_languages[$file->langcode][1];
    }
    else {
      // If the language was not found in standard.inc, display its langcode.
      $select_options[$file->langcode] = $file->langcode;
    }
    // Build a list of languages simulated for browser detection.
    $languages[$file->langcode] = (object) array(
      'langcode' => $file->langcode,
    );
  }

  $browser_langcode = locale_language_from_browser($languages);
  $form['langcode'] = array(
    '#type' => 'select',
    '#options' => $select_options,
    // Use the browser detected language as default or English if nothing found.
    '#default_value' => !empty($browser_langcode) ? $browser_langcode : 'en',
  );

  if (count($files) == 1) {
    $form['help'] = array(
      '#type' => 'help',
      '#markup' => '<a href="' . check_url(backdrop_current_script_url(array('translate' => 'true'))) . '">' . st('Learn how to install Backdrop in other languages') . '</a>',
    );
  }
  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => st('Save and continue'),
  );
  return $form;
}