Index: babel/catalog/extract.py
===================================================================
--- babel/catalog/extract.py	(revision 9)
+++ babel/catalog/extract.py	(working copy)
@@ -33,45 +33,50 @@
 
 GROUP_NAME = 'babel.extractors'
 
-KEYWORDS = (
-    '_', 'gettext', 'ngettext',
-    'dgettext', 'dngettext',
-    'ugettext', 'ungettext'
-)
+KEYWORDS = {
+    '_': None,
+    'gettext': None,
+    'ngettext': (1, 2),
+    'ugettext': None,
+    'ungettext': (1, 2),
+    'dgettext': (2,),
+    'dngettext': (2, 3),
+}
 
 DEFAULT_MAPPING = {
     'genshi': ['*.html', '**/*.html'],
     'python': ['*.py', '**/*.py']
 }
 
+
 def extract_from_dir(dirname, mapping=DEFAULT_MAPPING, keywords=KEYWORDS,
                      options=None):
     """Extract messages from any source files found in the given directory.
-    
+
     This function generates tuples of the form:
-    
+
         ``(filename, lineno, funcname, message)``
-    
+
     Which extraction method used is per file is determined by the `mapping`
     parameter, which maps extraction method names to lists of extended glob
     patterns. For example, the following is the default mapping:
-    
+
     >>> mapping = {
     ...     'python': ['*.py', '**/*.py']
     ... }
-    
+
     This basically says that files with the filename extension ".py" at any
     level inside the directory should be processed by the "python" extraction
     method. Files that don't match any of the patterns are ignored.
-    
+
     The following extended mapping would also use the "genshi" extraction method
     on any file in "templates" subdirectory:
-    
+
     >>> mapping = {
     ...     'genshi': ['**/templates/*.*', '**/templates/**/*.*'],
     ...     'python': ['*.py', '**/*.py']
     ... }
-    
+
     :param dirname: the path to the directory to extract messages from
     :param mapping: a mapping of extraction method names to extended glob
                     patterns
@@ -96,11 +101,11 @@
 
 def extract_from_file(method, filename, keywords=KEYWORDS, options=None):
     """Extract messages from a specific file.
-    
+
     This function returns a list of tuples of the form:
-    
+
         ``(lineno, funcname, message)``
-    
+
     :param filename: the path to the file to extract messages from
     :param method: a string specifying the extraction method (.e.g. "python")
     :param keywords: a list of keywords (i.e. function names) that should be
@@ -118,14 +123,14 @@
 def extract(method, fileobj, keywords=KEYWORDS, options=None):
     """Extract messages from the given file-like object using the specified
     extraction method.
-    
+
     This function returns a list of tuples of the form:
-    
+
         ``(lineno, funcname, message)``
-    
+
     The implementation dispatches the actual extraction to plugins, based on the
     value of the ``method`` parameter.
-    
+
     >>> source = '''# foo module
     ... def run(argv):
     ...    print _('Hello, world!')
@@ -135,7 +140,7 @@
     >>> for message in extract('python', StringIO(source)):
     ...     print message
     (3, '_', 'Hello, world!')
-    
+
     :param method: a string specifying the extraction method (.e.g. "python")
     :param fileobj: the file-like object the messages should be extracted from
     :param keywords: a list of keywords (i.e. function names) that should be
@@ -147,12 +152,25 @@
     """
     for entry_point in working_set.iter_entry_points(GROUP_NAME, method):
         func = entry_point.load(require=True)
-        return list(func(fileobj, keywords, options=options or {}))
+        m = []
+        for lineno, funcname, messages in func(fileobj, keywords.keys(),
+                                               options=options or {}):
+            if isinstance(messages, (list, tuple)):
+                indices = keywords[funcname]
+                msgs = []
+                for indice in indices:
+                    msgs.append(messages[indice-1])
+                messages = tuple(msgs)
+                if len(messages) == 1:
+                    messages = messages[0]
+            yield lineno, funcname, messages
+        return
+        #return list(func(fileobj, keywords, options=options or {}))
     raise ValueError('Unknown extraction method %r' % method)
 
 def extract_genshi(fileobj, keywords, options):
     """Extract messages from Genshi templates.
-    
+
     :param fileobj: the file-like object the messages should be extracted from
     :param keywords: a list of keywords (i.e. function names) that should be
                      recognized as translation functions
@@ -169,7 +187,7 @@
 
 def extract_python(fileobj, keywords, options):
     """Extract messages from Python source code.
-    
+
     :param fileobj: the file-like object the messages should be extracted from
     :param keywords: a list of keywords (i.e. function names) that should be
                      recognized as translation functions

