diff --git a/i18n/hggettext b/i18n/hggettext
index cc047a733f69ab160613d894ae61bf2cf37f7656_aTE4bi9oZ2dldHRleHQ=..16a175b3681e6b91e8cac46a89e41002f52a79d4_aTE4bi9oZ2dldHRleHQ= 100755
--- a/i18n/hggettext
+++ b/i18n/hggettext
@@ -112,4 +112,10 @@
 
     for func, rstrip in functions:
         if func.__doc__:
+            funcmod = inspect.getmodule(func)
+            extra = ''
+            if funcmod.__package__ == funcmod.__name__:
+                extra = '/__init__'
+            actualpath = '%s%s.py' % (funcmod.__name__.replace('.', '/'), extra)
+
             src = inspect.getsource(func)
@@ -115,7 +121,7 @@
             src = inspect.getsource(func)
-            name = "%s.%s" % (path, func.__name__)
+            name = "%s.%s" % (actualpath, func.__name__)
             lineno = inspect.getsourcelines(func)[1]
             doc = func.__doc__
             if rstrip:
                 doc = doc.rstrip()
             lineno += offset(src, doc, name, 1)
@@ -117,9 +123,9 @@
             lineno = inspect.getsourcelines(func)[1]
             doc = func.__doc__
             if rstrip:
                 doc = doc.rstrip()
             lineno += offset(src, doc, name, 1)
-            print(poentry(path, lineno, doc))
+            print(poentry(actualpath, lineno, doc))
 
 
 def rawtext(path):