function install_import_translations

install_import_translations(&$install_state)

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

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

Code

function install_import_translations(&$install_state) {
  \Drupal::moduleHandler()->loadInclude('locale', 'translation.inc');

  // If there is more than one language or the single one is not English, we
  // should import translations.
  $operations = install_download_additional_translations_operations($install_state);
  $languages = \Drupal::languageManager()->getLanguages();
  if (count($languages) > 1 || !isset($languages['en'])) {
    $operations[] = array('_install_prepare_import', array(array_keys($languages), $install_state['server_pattern']));

    // Set up a batch to import translations for drupal core. Translation import
    // for contrib modules happens in install_import_translations_remaining.
    foreach ($languages as $language) {
      if (locale_translation_use_remote_source()) {
        $operations[] = array('locale_translation_batch_fetch_download', array('drupal', $language->getId()));
      }
      $operations[] = array('locale_translation_batch_fetch_import', array('drupal', $language->getId(), array()));
    }

    module_load_include('fetch.inc', 'locale');
    $batch = array(
      'operations' => $operations,
      'title' => t('Updating translations.'),
      'progress_message' => '',
      'error_message' => t('Error importing translation files'),
      'finished' => 'locale_translation_batch_fetch_finished',
      'file' => drupal_get_path('module', 'locale') . '/locale.batch.inc',
    );
    return $batch;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!install.core.inc/function/install_import_translations/8.1.x