3

I'm having some trouble with removing the active language from the Language Switcher Dropdown module. I'm trying to override theme_languageicons_icon() with the following code, but it doesn't seem to work.

function themename_languageicons_icon(&$variables) {
  global $language;

  foreach ($variables as $varKey => $value) {
    if ($variables['language']->language == $language->language) {
      unset($variables[$varKey]);
      break;    
    }
  }

  return theme('links', $variables);
}

Do you have any idea on how to achieve this? I don't want to disable the active language using CSS since I'm having different style properties for the first-child and last-child of the list.

2
  • 1
    Have you considered blind and other people with disabilities? For them selecting language that's active may be easiest way to cancel selection they entered unintentionally, and you want to take it away from them. Do you really want to make their lives a tiny bit harder than it already is?
    – Mołot
    Commented Aug 2, 2013 at 11:41
  • Well I never really considered that thank you for pointing it out, but I still want to know how to remove the active language from the list since its a design requirement. Commented Aug 2, 2013 at 11:52

1 Answer 1

0

For a similar problem (removing the language switch links for non-translated equivalent pages), I've implemented hook_language_switch_links_alter() in my theme.

Although I haven't tried it out myself, I think the code example will point you in the right direction. Instead of setting an 'active-language' class attribute, you can unset the link.

function mymodule_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';
    }
  }
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.