Hi,

When I create a menu entry with menuux, the language of the menu item is always set as "undefined". Disabling menuux, re-saving a node with a menu item attached to it, and the item receives a language. When handling create/edit/update of menu items, do you take i18n_menu into account?

Regards,
Oliver

Comments

Anonymous’s picture

Here's a dirty hack to get the language field set in the menu items table based on the language chosen on the node add/edit form. Doesn't take into account translation sets et cetera, but I'm not sure if that's even necessary at this point?

/**
 * Handle the menubrowser part of nodes being inserted or updated
 *
 * @param object $node
 *  The node beeing inserted/updated
 */
function menuux_node_form_submit(&$node) {
  if (!empty($node->fmenu['mlid']) && $node->fmenu['menu_name'] == '0') {
    menu_link_delete($node->fmenu['mlid']);
    return;
  }
  $link = array(
    'link_title' => trim($node->fmenu['link_title']),
    'link_path' => "node/$node->nid",
    'menu_name' => $node->fmenu['menu_name'],
  );
+  // add language field if i18n_menu is enabled to provide a sketchy i18n implementation
+  if(module_exists('i18n_menu')) {
+   $link['language'] = $node->language;
+  }
  if (!empty($node->fmenu['mlid'])) {
    $link['mlid'] = $node->fmenu['mlid'];
    $link['has_children'] = $node->fmenu['has_children'];
    if (empty($node->fmenu['related_link'])) {
      if ($node->fmenu['link_title'] != $node->fmenu['old_link_title']) {
        $link['plid'] = $node->fmenu['plid'];
        $link['weight'] = $node->fmenu['weight'];
      }
      elseif ($node->fmenu['menu_name'] == $node->fmenu['old_menu_name']) {
        return;
      }
    }
  }
stolzenhain’s picture

Hello! Just stumbled over the same problem – thanks for the hint – a more robust approach for a fix would be very much appreciated.

Anonymous’s picture

The "fix" I posted above works however, I run it on multiple productive sites without problems. However: I forked the module locally to make some other adjustments related to i18n since this aspect isn't covered at all by the module itself, but my changes are very specific, related to my projects. I would love to see built-in i18n support too, but I think this is something the module's maintainer has to look into. I shared another patch in the issue queue related to i18n which should be helpful as a starting point for a proper integration.

stolzenhain’s picture

Just adding for reference:

Also, in the issue queue there is another language-related bug+fix: