Form constructor for the language selection form.
$files: An associative array of file information objects keyed by file URIs as returned by file_scan_directory().
function install_select_language_form($form, &$form_state, $files) {
include_once DRUPAL_ROOT . '/core/includes/standard.inc';
include_once DRUPAL_ROOT . '/core/modules/language/language.module';
include_once DRUPAL_ROOT . '/core/modules/language/language.negotiation.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] = new Language(array(
'langcode' => $file->langcode,
));
}
$browser_langcode = 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(
'#markup' => '<p><a href="' . check_url(drupal_current_script_url(array(
'translate' => 'true',
))) . '">' . st('Learn how to install Drupal in other languages') . '</a></p>',
);
}
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => st('Save and continue'),
);
return $form;
}