diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 3711912..7ecd5a2 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -545,6 +545,22 @@ function install_tasks($install_state) { 'display' => count($install_state['profiles']) != 1, 'run' => INSTALL_TASK_RUN_IF_REACHED, ), + ); + + // The order of the first two installation tasks depends on whether any + // available install profile needs to modify the language selection process. + // If so, the profile selection task must come first, so that the profile is + // able to make the desired modifications once it is chosen. + foreach ($install_state['profiles'] as $profile) { + $info = install_profile_info($profile->name); + if (!empty($info['custom_language_selection'])) { + $tasks = array_reverse($tasks, TRUE); + break; + } + } + + // Add the next set of core installation tasks. + $tasks += array( 'install_load_profile' => array( 'run' => INSTALL_TASK_RUN_IF_REACHED, ), diff --git a/core/includes/install.inc b/core/includes/install.inc index 470586c..89a49d4 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -1231,6 +1231,22 @@ function drupal_check_module($module) { * - distribution_name: The name of the Drupal distribution that is being * installed, to be shown throughout the installation process. Defaults to * 'Drupal'. + * - langcode: Profiles which want to automatically pre-select a language for + * the user (skipping the installer's language selection task) should set + * this parameter to the desired language code. This must be a valid, + * available language in order to work correctly. Note that setting this also + * forces the custom_language_selection parameter below to be TRUE (since by + * definition it means Drupal's default language selection method has been + * altered). Defaults to NULL. + * - custom_language_selection: Profiles which want to customize or replace the + * default installer language selection task must set this to TRUE. This will + * cause the installer to run the profile selection task before the language + * selection task, so that if the user does wind up choosing this profile, + * the profile can alter the language selection task using normal methods, + * such as hook_install_tasks_alter(). Because this change of order results + * in a more difficult profile selection experience for non-English speakers, + * you should only use this parameter if absolutely necessary. Defaults to + * FALSE. * * Note that this function does an expensive file system scan to get info file * information for dependencies. If you only need information from the info diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 51f0ecb..a639bcd 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -3255,6 +3255,16 @@ function hook_html_head_alter(&$head_elements) { * You can use this hook to change or replace any part of the Drupal * installation process that occurs after the installation profile is selected. * + * You can also use this hook to modify the language selection task (which by + * default comes before the profile selection) but only if you also set the + * special 'custom_language_selection' property in your profile's .info file, + * as described in install_profile_info(). This will cause the installer to run + * the profile selection task before the language selection task, thereby + * allowing your profile's modifications to the language selection task to take + * effect. Because this change of order results in a more difficult profile + * selection experience for non-English speakers, you should only do it if + * absolutely necessary. + * * @param $tasks * An array of all available installation tasks, including those provided by * Drupal core. You can modify this array to change or replace individual @@ -3265,9 +3275,9 @@ function hook_html_head_alter(&$head_elements) { * @see install_profile_info() */ function hook_install_tasks_alter(&$tasks, $install_state) { - // Replace the entire site configuration form provided by Drupal core + // Replace the "Choose language" installation task provided by Drupal core // with a custom callback function defined by this installation profile. - $tasks['install_configure_form']['function'] = 'myprofile_install_configure_form'; + $tasks['install_select_language']['function'] = 'myprofile_language_selection'; } /**