summaryrefslogtreecommitdiff
path: root/sphinx/environment
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/environment')
-rw-r--r--sphinx/environment/__init__.py25
-rw-r--r--sphinx/environment/adapters/indexentries.py4
-rw-r--r--sphinx/environment/adapters/toctree.py11
-rw-r--r--sphinx/environment/collectors/asset.py7
-rw-r--r--sphinx/environment/collectors/toctree.py5
5 files changed, 28 insertions, 24 deletions
diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py
index 7ef7dec53..136953616 100644
--- a/sphinx/environment/__init__.py
+++ b/sphinx/environment/__init__.py
@@ -31,6 +31,7 @@ from sphinx.environment.adapters.indexentries import IndexEntries
from sphinx.environment.adapters.toctree import TocTree
from sphinx.errors import SphinxError, ExtensionError
from sphinx.io import read_doc
+from sphinx.locale import __
from sphinx.transforms import SphinxTransformer
from sphinx.util import get_matching_docs, FilenameUniqDict
from sphinx.util import logging, rst
@@ -277,9 +278,9 @@ class BuildEnvironment(object):
raise ValueError('invalid versioning method: %r' % method)
condition = versioning_conditions[method]
if self.versioning_condition not in (None, condition):
- raise SphinxError('This environment is incompatible with the '
- 'selected builder, please choose another '
- 'doctree directory.')
+ raise SphinxError(__('This environment is incompatible with the '
+ 'selected builder, please choose another '
+ 'doctree directory.'))
self.versioning_condition = condition
self.versioning_compare = compare
@@ -305,9 +306,9 @@ class BuildEnvironment(object):
If needed, this method returns the reason for refresh.
"""
if self.version != app.registry.get_envversion(app):
- return True, 'build environment version not current'
+ return True, __('build environment version not current')
elif self.srcdir != app.srcdir:
- return True, 'source directory has changed'
+ return True, __('source directory has changed')
else:
return False, None
@@ -426,7 +427,7 @@ class BuildEnvironment(object):
if os.access(self.doc2path(docname), os.R_OK):
self.found_docs.add(docname)
else:
- logger.warning("document not readable. Ignored.", location=docname)
+ logger.warning(__("document not readable. Ignored."), location=docname)
# Current implementation is applying translated messages in the reading
# phase.Therefore, in order to apply the updated message catalog, it is
@@ -511,19 +512,19 @@ class BuildEnvironment(object):
"""Update configurations by new one."""
changed_reason = ''
if self.config is None:
- changed_reason = 'new config'
+ changed_reason = __('new config')
else:
# check if a config value was changed that affects how
# doctrees are read
for confval in config.filter('env'):
if self.config[confval.name] != confval.value:
- changed_reason = 'config changed'
+ changed_reason = __('config changed')
break
# this value is not covered by the above loop because it is handled
# specially by the config class
if self.config.extensions != config.extensions:
- changed_reason = 'extensions changed'
+ changed_reason = __('extensions changed')
# the source and doctree directories may have been relocated
self.srcdir = srcdir
@@ -686,7 +687,7 @@ class BuildEnvironment(object):
try:
return self.domains[domainname]
except KeyError:
- raise ExtensionError('Domain %r is not registered' % domainname)
+ raise ExtensionError(__('Domain %r is not registered') % domainname)
# --------- RESOLVING REFERENCES AND TOCTREES ------------------------------
@@ -796,7 +797,7 @@ class BuildEnvironment(object):
def traverse_toctree(parent, docname):
# type: (unicode, unicode) -> Iterator[Tuple[unicode, unicode]]
if parent == docname:
- logger.warning('self referenced toctree found. Ignored.', location=docname)
+ logger.warning(__('self referenced toctree found. Ignored.'), location=docname)
return
# traverse toctree by pre-order
@@ -836,7 +837,7 @@ class BuildEnvironment(object):
continue
if 'orphan' in self.metadata[docname]:
continue
- logger.warning('document isn\'t included in any toctree',
+ logger.warning(__('document isn\'t included in any toctree'),
location=docname)
# call check-consistency for all extensions
diff --git a/sphinx/environment/adapters/indexentries.py b/sphinx/environment/adapters/indexentries.py
index db33a76a7..3e1f47c6e 100644
--- a/sphinx/environment/adapters/indexentries.py
+++ b/sphinx/environment/adapters/indexentries.py
@@ -16,7 +16,7 @@ from typing import TYPE_CHECKING
from six import text_type, iteritems
-from sphinx.locale import _
+from sphinx.locale import _, __
from sphinx.util import split_into, logging
if TYPE_CHECKING:
@@ -89,7 +89,7 @@ class IndexEntries(object):
add_entry(first, _('see also %s') % second, None,
link=False, key=index_key)
else:
- logger.warning('unknown index entry type %r', type, location=fn)
+ logger.warning(__('unknown index entry type %r'), type, location=fn)
except ValueError as err:
logger.warning(str(err), location=fn)
diff --git a/sphinx/environment/adapters/toctree.py b/sphinx/environment/adapters/toctree.py
index aeba0cc08..920c4b502 100644
--- a/sphinx/environment/adapters/toctree.py
+++ b/sphinx/environment/adapters/toctree.py
@@ -15,6 +15,7 @@ from docutils import nodes
from six import iteritems
from sphinx import addnodes
+from sphinx.locale import __
from sphinx.util import url_re, logging
from sphinx.util.nodes import clean_astext, process_only_nodes
@@ -148,8 +149,8 @@ class TocTree(object):
toc = nodes.bullet_list('', item)
else:
if ref in parents:
- logger.warning('circular toctree references '
- 'detected, ignoring: %s <- %s',
+ logger.warning(__('circular toctree references '
+ 'detected, ignoring: %s <- %s'),
ref, ' <- '.join(parents),
location=ref)
continue
@@ -167,12 +168,12 @@ class TocTree(object):
refnode.children = [nodes.Text(title)]
if not toc.children:
# empty toc means: no titles will show up in the toctree
- logger.warning('toctree contains reference to document %r that '
- 'doesn\'t have a title: no link will be generated',
+ logger.warning(__('toctree contains reference to document %r that '
+ 'doesn\'t have a title: no link will be generated'),
ref, location=toctreenode)
except KeyError:
# this is raised if the included file does not exist
- logger.warning('toctree contains reference to nonexisting document %r',
+ logger.warning(__('toctree contains reference to nonexisting document %r'),
ref, location=toctreenode)
else:
# if titles_only is given, only keep the main title and
diff --git a/sphinx/environment/collectors/asset.py b/sphinx/environment/collectors/asset.py
index d33d8f665..06af528c1 100644
--- a/sphinx/environment/collectors/asset.py
+++ b/sphinx/environment/collectors/asset.py
@@ -20,6 +20,7 @@ from six import iteritems, itervalues
from sphinx import addnodes
from sphinx.environment.collectors import EnvironmentCollector
+from sphinx.locale import __
from sphinx.util import logging
from sphinx.util.i18n import get_image_filename_for_language, search_image_for_language
from sphinx.util.images import guess_mimetype
@@ -89,7 +90,7 @@ class ImageCollector(EnvironmentCollector):
for imgpath in itervalues(candidates):
app.env.dependencies[docname].add(imgpath)
if not os.access(path.join(app.srcdir, imgpath), os.R_OK):
- logger.warning('image file not readable: %s' % imgpath,
+ logger.warning(__('image file not readable: %s') % imgpath,
location=node, type='image', subtype='not_readable')
continue
app.env.images.add_file(docname, imgpath)
@@ -105,7 +106,7 @@ class ImageCollector(EnvironmentCollector):
if mimetype not in candidates:
globbed.setdefault(mimetype, []).append(new_imgpath)
except (OSError, IOError) as err:
- logger.warning('image file %s not readable: %s' % (filename, err),
+ logger.warning(__('image file %s not readable: %s') % (filename, err),
location=node, type='image', subtype='not_readable')
for key, files in iteritems(globbed):
candidates[key] = sorted(files, key=len)[0] # select by similarity
@@ -130,7 +131,7 @@ class DownloadFileCollector(EnvironmentCollector):
rel_filename, filename = app.env.relfn2path(targetname, app.env.docname)
app.env.dependencies[app.env.docname].add(rel_filename)
if not os.access(filename, os.R_OK):
- logger.warning('download file not readable: %s' % filename,
+ logger.warning(__('download file not readable: %s') % filename,
location=node, type='download', subtype='not_readable')
continue
node['filename'] = app.env.dlfiles.add_file(app.env.docname, filename)
diff --git a/sphinx/environment/collectors/toctree.py b/sphinx/environment/collectors/toctree.py
index 27fca5540..5ff03da39 100644
--- a/sphinx/environment/collectors/toctree.py
+++ b/sphinx/environment/collectors/toctree.py
@@ -17,6 +17,7 @@ from six import iteritems
from sphinx import addnodes
from sphinx.environment.adapters.toctree import TocTree
from sphinx.environment.collectors import EnvironmentCollector
+from sphinx.locale import __
from sphinx.transforms import SphinxContentsFilter
from sphinx.util import url_re, logging
@@ -189,8 +190,8 @@ class TocTreeCollector(EnvironmentCollector):
# don't mess with those
continue
elif ref in assigned:
- logger.warning('%s is already assigned section numbers '
- '(nested numbered toctree?)', ref,
+ logger.warning(__('%s is already assigned section numbers '
+ '(nested numbered toctree?)'), ref,
location=toctreenode, type='toc', subtype='secnum')
elif ref in env.tocs:
secnums = env.toc_secnumbers[ref] = {}