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
Comment #1
Anonymous (not verified) commentedI, too, would like that.
Unfortunately I've been searching the way to do it and no luck.
Comment #2
rboedeker commentedhttp://drupal.org/node/313814 works for me. Good luck