How to make language switcher links link to frontpage in Drupal 7



Edit your theme's template.php-file (or create one if it does not exist) and add the following lines:

 * Implements hook_language_switch_links_alter().
function MYTHEME_language_switch_links_alter(&$links, $type, $path) {
  global $language;
  if ($type == LANGUAGE_TYPE_INTERFACE && isset($links[$language->language])) {
    foreach ($links as $langcode => &$link) {
      $link['href'] = '<front>';

Change "MYTHEME" to your theme's name.


In my default installation it displays the corresponding language name struck out. I find that less confusing than being redirected to the front page if a translation doesn't exist.

As a visitor, I hate sites that send me to the front page, so I can start navigating or searching again for the content that I just found. You should really reconsider this. Boromino's idea seems much better regarding usability.

Just my 2 cents.

Maybe a more sensible approach is to create a single page for each language explaining there’s no available translation for the current content.

Roman's picture
Wed, 04/11/2018 - 18:35

Thank you so much! I have been looking for this for hours! :-D

Jack J. 's picture
Jack J.
Tue, 04/04/2017 - 17:29

Hello! Maybe it is a good idea to check out a translation management platform like to better manage translations.

linm's picture
Tue, 05/01/2018 - 15:58

The "active" class is gone though…

Any solution?

Add new comment