*** menu.c.old	Sun Mar 30 15:56:18 2008
--- menu.c	Sun Mar 30 16:09:01 2008
***************
*** 46,51 ****
--- 46,53 ----
  static int s_tearoffs = FALSE;
  #endif
  
+ static vimmenu_T *menu_item_find __ARGS((char_u *descriptor));
+ 
  static int menu_is_hidden __ARGS((char_u *name));
  #if defined(FEAT_CMDL_COMPL) || (defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF))
  static int menu_is_tearoff __ARGS((char_u *name));
***************
*** 2123,2149 ****
  
  #endif /* FEAT_GUI_W32 && FEAT_TEAROFF */
  
! /*
!  * Given a menu descriptor, e.g. "File.New", find it in the menu hierarchy and
!  * execute it.
!  */
!     void
! ex_emenu(eap)
!     exarg_T	*eap;
  {
      vimmenu_T	*menu;
      char_u	*name;
      char_u	*saved_name;
      char_u	*p;
-     int		idx;
-     char_u	*mode;
  
!     saved_name = vim_strsave(eap->arg);
      if (saved_name == NULL)
! 	return;
  
      menu = root_menu;
-     name = saved_name;
      while (*name)
      {
  	/* Find in the menu hierarchy */
--- 2125,2184 ----
  
  #endif /* FEAT_GUI_W32 && FEAT_TEAROFF */
  
!     static vimmenu_T *
! menu_item_find(descriptor)
!     char_u  *descriptor;
  {
      vimmenu_T	*menu;
      char_u	*name;
      char_u	*saved_name;
      char_u	*p;
  
! #ifdef FEAT_MULTI_LANG
!     char_u	*menu_path;
!     char_u	*map_to;
!     int		len;
!     char_u	*new_cmd;
!     char_u	*tofree = NULL;
! #endif
! 
!     saved_name = vim_strsave(descriptor);
      if (saved_name == NULL)
! 	return NULL;
!     name = saved_name;
! 
! #ifdef FEAT_MULTI_LANG
!     /*
!      * Translate menu names as specified with ":menutrans" commands.
!      */
!     menu_path = name;
!     while (*menu_path)
!     {
! 	/* find the end of one part and check if it should be translated */
! 	p = menu_skip_part(menu_path);
! 	map_to = menutrans_lookup(menu_path, (int)(p - menu_path));
! 	if (map_to != NULL)
! 	{
! 	    /* found a match: replace with the translated part */
! 	    len = (int)STRLEN(map_to);
! 	    new_cmd = alloc((unsigned)STRLEN(name) + len + 1);
! 	    if (new_cmd == NULL)
! 		break;
! 	    mch_memmove(new_cmd, name, menu_path - name);
! 	    mch_memmove(new_cmd + (menu_path - name), map_to, (size_t)len);
! 	    STRCPY(new_cmd + (menu_path - name) + len, p);
! 	    p = new_cmd + (menu_path - name) + len;
! 	    vim_free(tofree);
! 	    tofree = new_cmd;
! 	    name = new_cmd;
! 	}
! 	if (*p != '.')
! 	    break;
! 	menu_path = p + 1;
!     }
! #endif
  
      menu = root_menu;
      while (*name)
      {
  	/* Find in the menu hierarchy */
***************
*** 2173,2178 ****
--- 2208,2234 ----
  	name = p;
      }
      vim_free(saved_name);
+ 
+ #ifdef FEAT_MULTI_LANG
+     vim_free(tofree);
+ #endif
+ 
+     return menu;
+ }
+ 
+ /*
+  * Given a menu descriptor, e.g. "File.New", find it in the menu hierarchy and
+  * execute it.
+  */
+     void
+ ex_emenu(eap)
+     exarg_T	*eap;
+ {
+     vimmenu_T	*menu;
+     int		idx;
+     char_u	*mode;
+ 
+     menu = menu_item_find(eap->arg);
      if (menu == NULL)
      {
  	EMSG2(_("E334: Menu not found: %s"), eap->arg);
