mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #6746 from tk0miya/6743_rst_prolog_breaks_i18n
Fix #6743: i18n: rst_prolog breaks the translation
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -32,6 +32,7 @@ Bugs fixed
|
||||
* #6655: image URLs containing ``data:`` causes gettext builder crashed
|
||||
* #6584: i18n: Error when compiling message catalogs on Hindi
|
||||
* #6718: i18n: KeyError is raised if section title and table title are same
|
||||
* #6743: i18n: :confval:`rst_prolog` breaks the translation
|
||||
* #6708: mathbase: Some deprecated functions have removed
|
||||
* #6709: autodoc: mock object does not work as a class decorator
|
||||
* #5070: epub: Wrong internal href fragment links
|
||||
|
||||
@@ -53,21 +53,28 @@ def publish_msgstr(app: "Sphinx", source: str, source_path: str, source_line: in
|
||||
:return: document
|
||||
:rtype: docutils.nodes.document
|
||||
"""
|
||||
from sphinx.io import SphinxI18nReader
|
||||
reader = SphinxI18nReader()
|
||||
reader.setup(app)
|
||||
parser = app.registry.create_source_parser(app, 'restructuredtext')
|
||||
doc = reader.read(
|
||||
source=StringInput(source=source,
|
||||
source_path="%s:%s:<translated>" % (source_path, source_line)),
|
||||
parser=parser,
|
||||
settings=settings,
|
||||
)
|
||||
try:
|
||||
doc = doc[0] # type: ignore
|
||||
except IndexError: # empty node
|
||||
pass
|
||||
return doc
|
||||
# clear rst_prolog temporarily
|
||||
rst_prolog = config.rst_prolog
|
||||
config.rst_prolog = None # type: ignore
|
||||
|
||||
from sphinx.io import SphinxI18nReader
|
||||
reader = SphinxI18nReader()
|
||||
reader.setup(app)
|
||||
parser = app.registry.create_source_parser(app, 'restructuredtext')
|
||||
doc = reader.read(
|
||||
source=StringInput(source=source,
|
||||
source_path="%s:%s:<translated>" % (source_path, source_line)),
|
||||
parser=parser,
|
||||
settings=settings,
|
||||
)
|
||||
try:
|
||||
doc = doc[0] # type: ignore
|
||||
except IndexError: # empty node
|
||||
pass
|
||||
return doc
|
||||
finally:
|
||||
config.rst_prolog = rst_prolog # type: ignore
|
||||
|
||||
|
||||
class PreserveTranslatableMessages(SphinxTransform):
|
||||
|
||||
Reference in New Issue
Block a user