function language_tour_tips_alter

Same name in other branches
  1. 9 core/modules/language/language.module \language_tour_tips_alter()
  2. 8.9.x core/modules/language/language.module \language_tour_tips_alter()
  3. 11.x core/modules/language/language.module \language_tour_tips_alter()

Implements hook_tour_tips_alter().

File

core/modules/language/language.module, line 420

Code

function language_tour_tips_alter(array &$tour_tips, EntityInterface $entity) {
    $module_extension_list = \Drupal::service('extension.list.module');
    foreach ($tour_tips as $tour_tip) {
        if ($tour_tip->get('id') == 'language-overview') {
            $additional_overview = '';
            if (Drupal::service('module_handler')->moduleExists('locale')) {
                $additional_overview = t("This page also provides an overview of how much of the site's interface has been translated for each configured language.");
            }
            else {
                $additional_overview = t("If the Interface Translation module is installed, this page will provide an overview of how much of the site's interface has been translated for each configured language.");
            }
            $tour_tip->set('body', $tour_tip->get('body') . '<p>' . $additional_overview . '</p>');
        }
        elseif ($tour_tip->get('id') == 'language-continue') {
            $additional_continue = '';
            $additional_modules = [];
            if (!Drupal::service('module_handler')->moduleExists('locale')) {
                $additional_modules[] = $module_extension_list->getName('locale');
            }
            if (!Drupal::service('module_handler')->moduleExists('content_translation')) {
                $additional_modules[] = $module_extension_list->getName('content_translation');
            }
            if (!empty($additional_modules)) {
                $additional_continue = t('Depending on your site features, additional modules that you might want to install are:') . '<ul>';
                foreach ($additional_modules as $additional_module) {
                    $additional_continue .= '<li>' . $additional_module . '</li>';
                }
                $additional_continue .= '</ul>';
            }
            if (!empty($additional_continue)) {
                $tour_tip->set('body', $tour_tip->get('body') . '<p>' . $additional_continue . '</p>');
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.