Fix error message wording in builders/latex/transforms.py

And make it and the two other ones there translatable strings.
Using .format for the f-string.
This commit is contained in:
Jean-François B
2023-03-31 23:58:48 +02:00
parent 40ec190353
commit 6809ca7d04

View File

@@ -18,6 +18,7 @@ from sphinx.builders.latex.nodes import (
thebibliography,
)
from sphinx.domains.citation import CitationDomain
from sphinx.locale import __
from sphinx.transforms import SphinxTransform
from sphinx.transforms.post_transforms import SphinxPostTransform
from sphinx.util.nodes import NodeMatcher
@@ -110,8 +111,9 @@ class ShowUrlsTransform(SphinxPostTransform):
try:
source = node['source'] # type: ignore[index]
except TypeError:
raise ValueError('Failed to get a docname!') from None
raise ValueError(f'Failed to get a docname for source {source!r}!')
raise ValueError(__('Failed to get a docname!')) from None
raise ValueError(__('Failed to get a docname '
'for source {source!r}!').format(source=source))
def create_footnote(
self, uri: str, docname: str,
@@ -471,7 +473,7 @@ class LaTeXFootnoteVisitor(nodes.NodeVisitor):
if docname == footnote['docname'] and footnote['ids'][0] == node['refid']:
return footnote
raise ValueError('No footnote not found for given reference node %r' % node)
raise ValueError(__('No footnote was found for given reference node %r') % node)
class BibliographyTransform(SphinxPostTransform):