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

Form constructor for the language selection form.

Related topics

File

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

Code

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

  $select_options = array();
  $browser_options = array();

  $form['#title'] = st('Choose language');

  // 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.
  // Select lists based on all standard languages.
  foreach ($standard_languages as $langcode => $language_names) {
    $select_options[$langcode] = isset($language_names[1]) ? $language_names[1] : $language_names[0];
    // Build a list of languages simulated for browser detection.
    $browser_options[$langcode] = (object) array(
      'langcode' => $langcode,
    );
  }
  asort($select_options);

  $browser_langcode = locale_language_from_browser($browser_options);
  $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($standard_languages) == 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;
}