install_download_additional_translations_operations(&$install_state)
Prepares the system for import and downloads additional translations.
Parameters
$install_state: An array of information about the current installation state.
Return value
The batch definition, if there are language files to download.
File
- core/includes/install.core.inc, line 1579
- API functions for installing Drupal.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | function install_download_additional_translations_operations(& $install_state ) { \Drupal::moduleHandler()->loadInclude( 'locale' , 'bulk.inc' ); $langcode = $install_state [ 'parameters' ][ 'langcode' ]; if (!( $language = ConfigurableLanguage::load( $langcode ))) { // Create the language if not already shipped with a profile. $language = ConfigurableLanguage::createFromLangcode( $langcode ); } $language ->save(); // If a non-English language was selected, change the default language and // remove English. if ( $langcode != 'en' ) { \Drupal::configFactory()->getEditable( 'system.site' ) ->set( 'langcode' , $langcode ) ->set( 'default_langcode' , $langcode ) ->save(); \Drupal::service( 'language.default' )->set( $language ); if ( empty ( $install_state [ 'profile_info' ][ 'keep_english' ])) { entity_delete_multiple( 'configurable_language' , array ( 'en' )); } } // If there is more than one language or the single one is not English, we // should download/import translations. $languages = \Drupal::languageManager()->getLanguages(); $operations = array (); foreach ( $languages as $langcode => $language ) { // The installer language was already downloaded. Check downloads for the // other languages if any. Ignore any download errors here, since we // are in the middle of an install process and there is no way back. We // will not import what we cannot download. if ( $langcode != 'en' && $langcode != $install_state [ 'parameters' ][ 'langcode' ]) { $operations [] = array ( 'install_check_translations' , array ( $langcode , $install_state [ 'server_pattern' ])); } } return $operations ; } |
Please login to continue.