I often needed the functionality of the language switcher within a menu.

so I tried to write a module that uses hook_menu, to create dynamic menu items:

<?php

/**
 * Implements hook_menu().
 */

function language_switcher_menu_item_menu()
{
	$items = array();
  
	$path = drupal_is_front_page() ? '<front>' : $_GET['q'];
	$languages = language_list('enabled');
	foreach ($languages[1] as $language) {

		$items['language_switch_'.language] = array(
		'title' => $language->native,
		'description' => 'this content in another languge',
		'page callback' => drupal_goto($path),
		'access arguments' => array('access content'),
		'type' => MENU_CALLBACK,
		'menu_name' => 'menu-primary-links',
		
	  );
	}

  return $items;

}
?>

unfortunately that doesn't work,

wouldn't that be a useful feature?
would you please help me?

Comments

Anonymous’s picture

Category: feature » support
Issue tags: +menu, +superfish, +Language switch

I, too, would like that.

Unfortunately I've been searching the way to do it and no luck.

rboedeker’s picture

http://drupal.org/node/313814 works for me. Good luck

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.