function bootstrap_languages_preprocess_links__bootstrap_language_block in Bootstrap Languages 8
Implements hook_preprocess_HOOK().
Preprocess for links--bootstrap-language-block.html.twig.
File
- ./
bootstrap_languages.module, line 25 - Provides a Bootstrap dropdown button to switch between available languages.
Code
function bootstrap_languages_preprocess_links__bootstrap_language_block(&$vars) {
$vars['current_language'] = \Drupal::languageManager()
->getCurrentLanguage()
->getId();
$vars['languages'] = [];
foreach ($vars['links'] as $lang_key => $link) {
/** @var \Drupal\Core\Url $url */
$url = $link['link']['#url'];
$url_options = NestedArray::mergeDeep($url
->getOptions(), $link['link']['#options']);
$vars['languages'][$lang_key] = $url
->setOptions($url_options);
}
}