diff --git a/core/modules/language/src/Plugin/Block/LanguageBlock.php b/core/modules/language/src/Plugin/Block/LanguageBlock.php index 0502d2d..5e3f333 100644 --- a/core/modules/language/src/Plugin/Block/LanguageBlock.php +++ b/core/modules/language/src/Plugin/Block/LanguageBlock.php @@ -8,6 +8,8 @@ namespace Drupal\language\Plugin\Block; use Drupal\Core\Block\BlockBase; +use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Language\LanguageManager; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; @@ -95,4 +97,20 @@ public function build() { return $build; } + /** + * {@inheritdoc} + */ + public function blockForm($form, FormStateInterface $form_state) { + $form = parent::blockForm($form, $form_state); + $path = drupal_is_front_page() ? '' : Url::fromRoute(''); + list(, $type) = explode(':', $this->getPluginId()); + $links = $this->languageManager->getLanguageSwitchLinks($type, $path); + // Warn the user that if there are no links to show, the block won't appear. + if (empty($links)) { + drupal_set_message($this->t('You do not have any language detection method enabled that provides URL based detection. The language switcher module will not be shown.'), 'warning'); + } + + return $form; + } + }