function install_import_translations

Imports languages via a batch process during installation.

Parameters

$install_state: An array of information about the current installation state.

Return value

The batch definition, if there are language files to import.

File

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

Code

function install_import_translations(&$install_state) {
  include_once drupal_get_path('module', 'locale') . '/locale.bulk.inc';
  $langcode = $install_state['parameters']['langcode'];
  include_once DRUPAL_ROOT . '/core/includes/standard.inc';
  $standard_languages = standard_language_list();
  if (!isset($standard_languages[$langcode])) {

    // Drupal does not know about this language, so we prefill its values with
    // our best guess. The user will be able to edit afterwards.
    $language = new Language(array(
      'langcode' => $langcode,
      'name' => $langcode,
      'default' => TRUE,
    ));
    language_save($language);
  }
  else {

    // A known predefined language, details will be filled in properly.
    $language = new Language(array(
      'langcode' => $langcode,
      'default' => TRUE,
    ));
    language_save($language);
  }

  // If a non-english language was selected, remove English.
  if ($langcode != 'en') {
    language_delete('en');
  }

  // Collect files to import for this language.
  $batch = locale_translate_batch_import_files(array(
    'langcode' => $langcode,
  ));
  if (!empty($batch)) {
    return $batch;
  }
}