function hook_language_switch_links_alter
Same name in other branches
- 9 core/lib/Drupal/Core/Language/language.api.php \hook_language_switch_links_alter()
- 8.9.x core/lib/Drupal/Core/Language/language.api.php \hook_language_switch_links_alter()
- 10 core/lib/Drupal/Core/Language/language.api.php \hook_language_switch_links_alter()
- 11.x core/lib/Drupal/Core/Language/language.api.php \hook_language_switch_links_alter()
Perform alterations on language switcher links.
A language switcher link may need to point to a different path or use a translated link text before going through l(), which will just handle the path aliases.
Parameters
$links: Nested array of links keyed by language code.
$type: The language type the links will switch.
$path: The current path.
Related topics
1 function implements hook_language_switch_links_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- translation_language_switch_links_alter in modules/
translation/ translation.module - Implements hook_language_switch_links_alter().
1 invocation of hook_language_switch_links_alter()
- language_negotiation_get_switch_links in includes/
language.inc - Returns the language switch links for the given language.
File
-
modules/
system/ language.api.php, line 54
Code
function hook_language_switch_links_alter(array &$links, $type, $path) {
global $language;
if ($type == LANGUAGE_TYPE_CONTENT && isset($links[$language->language])) {
foreach ($links[$language->language] as $link) {
$link['attributes']['class'][] = 'active-language';
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.