How do I insert a localized menu item? When writing a custom module, what is the proper way to insert a localized menu via hook_menu or hook_menu_alter? By localized I mean not only the translated label - that'd be done using the t() function on title - but also having localized path and page callback.

I tried something like this:

function hook_menu() {
  global $language;
  $items = array();

  switch($language-&gt;language){
  case 'en':
    $items[] = array(
      'title' =&gt; 'Contact Us',
      'page callback' =&gt; 'drupal_goto',
      'page arguments' =&gt; array('node/285'),
      'access callback' =&gt; TRUE,
      'menu_name' =&gt; 'main-menu',
      'type' =&gt; MENU_NORMAL_ITEM,
    );
    break;
  case 'pl':
    $items[] = array(
      'title' =&gt; 'Kontakt',
      'page callback' =&gt; 'drupal_goto',
      'page arguments' =&gt; array('node/286'),
      'access callback' =&gt; TRUE,
      'menu_name' =&gt; 'main-menu',
      'type' =&gt; MENU_NORMAL_ITEM,
    );
    break;
  }
  return $items;
}


but this is not behaving properly - once created, the menu item stick at the original language regardless of subsequent language negotiations. So what is the way to go?



Edit after trying out the code provided in answers
OK, so I approached that topic afresh and tried out all of the three methods suggested below. The two programmatic methods have the culprit that the array key used to install the menu item (as in: $items['corporate/contact-us']) will display in the status bar on hover, regardless of the language chosen. This is cosmetic but I consider it a bad UX. The third - UI-based - method has a side-effect (which is not the point of the original question) but was tried out just for curiosity. The point of my question was - whether it was possible to install a localized menu item totally programatically, and get exact result as when done through UI. Looks like this is not quite possible, unless there's a piece of know-how that I'm missing.
The array returned from hook_menu() is cached, and each implementation of hook_menu() is only invoked when the cache is cleared, which what happens, for example, when a module is disabled/enabled.

If the users are redirected to a different node depending on the currently set language, then the code should be similar to the following one.

function mymodule_menu() {
  $item['mymodule_path'] = array(
    'title' =&gt; 'Contact Us',
    'page callback' =&gt; 'mymodule_redirect',
    'access callback' =&gt; TRUE,
    'menu_name' =&gt; 'main-menu',
    'type' =&gt; MENU_NORMAL_ITEM,
  );

  return $items;
} 

function mymodule_redirect() {
  global $language;

  switch ($language-&gt;language) {
    case 'en':
      $goto = 'node/285';
      break;

    case 'pl':
      $goto = 'node/286';
      break;

    // ...
  }

  if (isset($goto)) {
    drupal_goto($goto);
  }
}


The alternative would be:


Create a link through the user interface (admin/structure/menu/manage/main-menu/add)


Use the following code to alter where the link takes

function mymodule_menu_link_alter(&amp;$item) {
  if ($item['module'] == 'menu' &amp;&amp; $item['link_title'] == t('Contact us')) {
    $item['options']['alter'] = TRUE;
  }
}

function mymodule_translated_menu_link_alter(&amp;$item, $map) {
  global $language;

  if ($item['module'] == 'menu' &amp;&amp; $item['link_title'] == t('Contact us')) {
    switch ($language-&gt;language) {
      case 'pl':
        $item['link_path'] = 'node/286';
        break;

      // ...
    }
  }
}



The first hook is necessary, or hook_translated_menu_link_alter() is not invoked.

The module could also programmatically add the link to the main menu. In this case, the code I would implement is similar to the following one.

function mymodule_enable() {
  $item = array(
    'link_path' =&gt; 'node/285',
    'link_title' =&gt; t('Contact us'),
    'menu_name' =&gt; 'main-menu',
    'mlid' =&gt; 0,
    'plid' =&gt; 0,
    'module' =&gt; 'mymodule',
  );

  menu_link_save($item);
}

function mymodule_menu_link_alter(&amp;$item) {
  if ($item['module'] == 'mymodule' &amp;&amp; $item['link_title'] == t('Contact us')) {
    $item['options']['alter'] = TRUE;
  }
}

function mymodule_translated_menu_link_alter(&amp;$item, $map) {
  global $language;

  if ($item['module'] == 'mymodule' &amp;&amp; $item['link_title'] == t('Contact us')) {
    switch ($language-&gt;language) {
      case 'pl':
        $item['link_path'] = 'node/286';
        break;

      // ...
    }
  }
}