1

Having a bilingual site here. Some nodes are translated and language switcher works fine. But the switcher block also shows up on nodes which aren't translated. Then the untranslated language link has a different styling.

How can I hide the switcher when there's no (other) translation of the node? I looked up variables in all preprocess functions without finding any indicators. What do I have to look for? And how then can I hide the switcher?

1 Answer 1

0

In template.php add:

/**
 * hide language switcher if en-gb is not set
 */
function MYTHEME_links__locale_block(&$vars) {
  // made conditional if other languages are added later
  if(!isset($vars['links']['en-gb']['href'])) {
    unset($vars['links']['en-gb']);
  }
  // here is the condition
  if(count($vars['links']) <= 1) {
    return '';
  } else {
    return theme_links($vars);
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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