Fix i18n: messages in sphinx.directives.other are not translated

This commit is contained in:
Takeshi KOMIYA 2021-09-12 18:58:16 +09:00
parent fc2ca413ec
commit 5c4f741fff

View File

@ -18,7 +18,7 @@ from docutils.parsers.rst.directives.misc import Include as BaseInclude
from sphinx import addnodes
from sphinx.domains.changeset import VersionChange # NOQA # for compatibility
from sphinx.locale import _
from sphinx.locale import _, __
from sphinx.util import docname_join, logging, url_re
from sphinx.util.docutils import SphinxDirective
from sphinx.util.matching import Matcher, patfilter
@ -107,7 +107,7 @@ class TocTree(SphinxDirective):
toctree['entries'].append((None, docname))
toctree['includefiles'].append(docname)
if not docnames:
logger.warning('toctree glob pattern %r didn\'t match any documents',
logger.warning(__('toctree glob pattern %r didn\'t match any documents'),
entry, location=toctree)
else:
if explicit:
@ -128,9 +128,9 @@ class TocTree(SphinxDirective):
toctree['entries'].append((title, ref))
elif docname not in self.env.found_docs:
if excluded(self.env.doc2path(docname, None)):
message = 'toctree contains reference to excluded document %r'
message = __('toctree contains reference to excluded document %r')
else:
message = 'toctree contains reference to nonexisting document %r'
message = __('toctree contains reference to nonexisting document %r')
logger.warning(message, docname, location=toctree)
self.env.note_reread()
@ -138,7 +138,7 @@ class TocTree(SphinxDirective):
if docname in all_docnames:
all_docnames.remove(docname)
else:
logger.warning('duplicated entry found in toctree: %s', docname,
logger.warning(__('duplicated entry found in toctree: %s'), docname,
location=toctree)
toctree['entries'].append((title, docname))
@ -248,7 +248,7 @@ class Acks(SphinxDirective):
self.state.nested_parse(self.content, self.content_offset, node)
if len(node.children) != 1 or not isinstance(node.children[0],
nodes.bullet_list):
logger.warning('.. acks content is not a list',
logger.warning(__('.. acks content is not a list'),
location=(self.env.docname, self.lineno))
return []
return [node]
@ -273,7 +273,7 @@ class HList(SphinxDirective):
self.state.nested_parse(self.content, self.content_offset, node)
if len(node.children) != 1 or not isinstance(node.children[0],
nodes.bullet_list):
logger.warning('.. hlist content is not a list',
logger.warning(__('.. hlist content is not a list'),
location=(self.env.docname, self.lineno))
return []
fulllist = node.children[0]