mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Respect gettext_compact in message patching too.
This commit is contained in:
parent
77329bf497
commit
0f47e55787
@ -76,7 +76,8 @@ class I18nBuilder(Builder):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def write_doc(self, docname, doctree):
|
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):
|
for node, msg in extract_messages(doctree):
|
||||||
catalog.add(msg, node)
|
catalog.add(msg, node)
|
||||||
|
@ -41,7 +41,7 @@ from sphinx.util import url_re, get_matching_docs, docname_join, split_into, \
|
|||||||
FilenameUniqDict
|
FilenameUniqDict
|
||||||
from sphinx.util.nodes import clean_astext, make_refnode, extract_messages, \
|
from sphinx.util.nodes import clean_astext, make_refnode, extract_messages, \
|
||||||
WarningStream
|
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.matching import compile_matchers
|
||||||
from sphinx.util.pycompat import all, class_types
|
from sphinx.util.pycompat import all, class_types
|
||||||
from sphinx.util.websupport import is_commentable
|
from sphinx.util.websupport import is_commentable
|
||||||
@ -198,13 +198,15 @@ class Locale(Transform):
|
|||||||
settings, source = self.document.settings, self.document['source']
|
settings, source = self.document.settings, self.document['source']
|
||||||
# XXX check if this is reliable
|
# XXX check if this is reliable
|
||||||
assert source.startswith(env.srcdir)
|
assert source.startswith(env.srcdir)
|
||||||
docname = os.path.splitext(source[len(env.srcdir):].lstrip(os.sep))[0]
|
docname = path.splitext(path.relpath(source, env.srcdir))[0]
|
||||||
section = docname.split(os.sep, 1)[0]
|
textdomain = find_catalog(docname,
|
||||||
|
self.document.settings.gettext_compact)
|
||||||
|
|
||||||
# fetch translations
|
# fetch translations
|
||||||
dirs = [path.join(env.srcdir, x)
|
dirs = [path.join(env.srcdir, directory)
|
||||||
for x in env.config.locale_dirs]
|
for directory in env.config.locale_dirs]
|
||||||
catalog, has_catalog = init_locale(dirs, env.config.language, section)
|
catalog, has_catalog = init_locale(dirs, env.config.language,
|
||||||
|
textdomain)
|
||||||
if not has_catalog:
|
if not has_catalog:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -708,6 +710,7 @@ class BuildEnvironment:
|
|||||||
self.settings['input_encoding'] = self.config.source_encoding
|
self.settings['input_encoding'] = self.config.source_encoding
|
||||||
self.settings['trim_footnote_reference_space'] = \
|
self.settings['trim_footnote_reference_space'] = \
|
||||||
self.config.trim_footnote_reference_space
|
self.config.trim_footnote_reference_space
|
||||||
|
self.settings['gettext_compact'] = self.config.gettext_compact
|
||||||
|
|
||||||
self.patch_lookup_functions()
|
self.patch_lookup_functions()
|
||||||
|
|
||||||
|
@ -141,5 +141,5 @@ def safe_relpath(path, start=None):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def find_catalog(docname, config):
|
def find_catalog(docname, compaction):
|
||||||
return docname.split(SEP, 1)[0] if config.gettext_compact else docname
|
return docname.split(SEP, 1)[0] if compaction else docname
|
||||||
|
Loading…
Reference in New Issue
Block a user