hook_language_switch_link_alter

Versions
7
hook_language_switch_link_alter(array &$links, $type, $path)

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

Code

modules/locale/locale.api.php, line 40

<?php
function hook_language_switch_link_alter(array &$links, $type, $path) {
  global $language;

  if ($type == LANGUAGE_TYPE_CONTENT && isset($links[$language])) {
    foreach ($links[$language] as $link) {
      $link['attributes']['class'][] = 'active-language';
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.