--- ../gnome-doc-utils/xml2po/modes/docbook.py	2005-07-18 14:15:36.000000000 +0100
+++ ./xml2po/modes/docbook.py	2006-03-27 15:12:45.707130000 +0100
@@ -92,6 +92,18 @@
             child = child.next
         return None
 
+    def _find_menupath(self, node):
+        """Locate menupath node."""
+        if node.name == 'menupath':
+            return node
+        child = node.children
+        while child:
+            ret = self._find_menupath(child)
+            if ret:
+                return ret
+            child = child.next
+        return None
+
     def _find_lastcopyright(self, node):
         if not node.children:
             return None
@@ -142,6 +154,55 @@
         root = doc.getRootElement()
         self._output_images(root,msg)
 
+    def processMenuPath(self, doc, desktop_file):
+        """Find menu location using desktop_file and replace <menupath> tag with
+        menu location."""
+
+        # Load in menuLocation mode/class
+        module = __import__("menulocation")
+        modeModule = 'menuLocation'
+        menuLocation = getattr(module, modeModule)()
+
+        menu_path = menuLocation.locateMenu(desktop_file)
+
+        if menu_path is not None:
+            # Locate menupath element, to be replaced with menu 
+            root = doc.getRootElement()
+    	    menupath = self._find_menupath(root)
+
+            # Replace <menupath/> with menu structure found
+            if menupath:
+                # Get <menupath/>'s parent
+                menuparent = menupath.parent
+
+                # Remove <menupath/> node
+                menupath.unlinkNode()
+                menupath.freeNode()
+
+                # Split returned path
+                items = menu_path.split('|')
+
+                # Create the main menu <term> node
+                mainmenu = libxml2.newNode("term")
+                mainmenu.newChild(None, "guimenu", items[0])
+
+                # Create the submenu's/menuitem <list> nodes
+                listitem = libxml2.newNode("listitem")
+                para = listitem.newChild(None, "para", "Choose ")
+                menuchoice = para.newChild(None, "menuchoice", None)
+
+                for i in range(len(items)):
+                    if i == (len(items)-1):
+                        # Menu Item
+						menuchoice.newChild(None, "guimenuitem", items[i])
+                    elif i > 0:
+                        # Sub Menu
+                        menuchoice.newChild(None, "guisubmenu", items[i])
+
+                # Add mainmenu and list nodes to <menupath/>'s parent
+                menuparent.addChild(mainmenu)
+                menuparent.addChild(listitem)
+
     def postProcessXmlTranslation(self, doc, language, translators):
         """Sets a language and translators in "doc" tree.
         
