Robert Lehmann avatar Robert Lehmann committed e78f260

Respect gettext_compact in message patching too.

Comments (0)

Files changed (3)

sphinx/builders/gettext.py

         return
 
     def write_doc(self, docname, doctree):
-        catalog = self.catalogs[find_catalog(docname, self.config)]
+        catalog = self.catalogs[find_catalog(docname,
+                                             self.config.gettext_compact)]
 
         for node, msg in extract_messages(doctree):
             catalog.add(msg, node)

sphinx/environment.py

      FilenameUniqDict
 from sphinx.util.nodes import clean_astext, make_refnode, extract_messages, \
      WarningStream
-from sphinx.util.osutil import movefile, SEP, ustrftime
+from sphinx.util.osutil import movefile, SEP, ustrftime, find_catalog
 from sphinx.util.matching import compile_matchers
 from sphinx.util.pycompat import all, class_types
 from sphinx.util.websupport import is_commentable
         settings, source = self.document.settings, self.document['source']
         # XXX check if this is reliable
         assert source.startswith(env.srcdir)
-        docname = os.path.splitext(source[len(env.srcdir):].lstrip(os.sep))[0]
-        section = docname.split(os.sep, 1)[0]
+        docname = path.splitext(path.relpath(source, env.srcdir))[0]
+        textdomain = find_catalog(docname,
+                                  self.document.settings.gettext_compact)
 
         # fetch translations
-        dirs = [path.join(env.srcdir, x)
-                for x in env.config.locale_dirs]
-        catalog, has_catalog = init_locale(dirs, env.config.language, section)
+        dirs = [path.join(env.srcdir, directory)
+                for directory in env.config.locale_dirs]
+        catalog, has_catalog = init_locale(dirs, env.config.language,
+                                           textdomain)
         if not has_catalog:
             return
 
         self.settings['input_encoding'] = self.config.source_encoding
         self.settings['trim_footnote_reference_space'] = \
             self.config.trim_footnote_reference_space
+        self.settings['gettext_compact'] = self.config.gettext_compact
 
         self.patch_lookup_functions()
 

sphinx/util/osutil.py

     except ValueError:
         return path
 
-def find_catalog(docname, config):
-    return docname.split(SEP, 1)[0] if config.gettext_compact else docname
+def find_catalog(docname, compaction):
+    return docname.split(SEP, 1)[0] if compaction else docname
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.