mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix error in merge of 'stable'
modified: sphinx/builders/gettext.py
This commit is contained in:
parent
3743199576
commit
8f5d1e1050
@ -270,28 +270,34 @@ class MessageCatalogBuilder(I18nBuilder):
|
|||||||
ensuredir(path.join(self.outdir, path.dirname(textdomain)))
|
ensuredir(path.join(self.outdir, path.dirname(textdomain)))
|
||||||
|
|
||||||
pofn = path.join(self.outdir, textdomain + '.pot')
|
pofn = path.join(self.outdir, textdomain + '.pot')
|
||||||
with open(pofn, 'w', encoding='utf-8') as pofile: # type: ignore
|
output = StringIO()
|
||||||
pofile.write(POHEADER % data) # type: ignore
|
output.write(POHEADER % data)
|
||||||
|
|
||||||
for message in catalog.messages:
|
for message in catalog.messages:
|
||||||
positions = catalog.metadata[message]
|
positions = catalog.metadata[message]
|
||||||
|
|
||||||
if self.config.gettext_location:
|
if self.config.gettext_location:
|
||||||
# generate "#: file1:line1\n#: file2:line2 ..."
|
# generate "#: file1:line1\n#: file2:line2 ..."
|
||||||
pofile.write("#: %s\n" % "\n#: ".join( # type: ignore
|
output.write("#: %s\n" % "\n#: ".join(
|
||||||
"%s:%s" % (canon_path(
|
"%s:%s" % (canon_path(
|
||||||
safe_relpath(source, self.outdir)), line)
|
safe_relpath(source, self.outdir)), line)
|
||||||
for source, line, _ in positions))
|
for source, line, _ in positions))
|
||||||
if self.config.gettext_uuid:
|
if self.config.gettext_uuid:
|
||||||
# generate "# uuid1\n# uuid2\n ..."
|
# generate "# uuid1\n# uuid2\n ..."
|
||||||
pofile.write("# %s\n" % "\n# ".join( # type: ignore
|
output.write("# %s\n" % "\n# ".join(
|
||||||
uid for _, _, uid in positions))
|
uid for _, _, uid in positions))
|
||||||
|
|
||||||
# message contains *one* line of text ready for translation
|
# message contains *one* line of text ready for translation
|
||||||
message = message.replace('\\', r'\\'). \
|
message = message.replace('\\', r'\\'). \
|
||||||
replace('"', r'\"'). \
|
replace('"', r'\"'). \
|
||||||
replace('\n', '\\n"\n"')
|
replace('\n', '\\n"\n"')
|
||||||
pofile.write('msgid "%s"\nmsgstr ""\n\n' % message) # type: ignore
|
output.write('msgid "%s"\nmsgstr ""\n\n' % message)
|
||||||
|
|
||||||
|
content = output.getvalue()
|
||||||
|
|
||||||
|
if should_write(pofn, content):
|
||||||
|
with open(pofn, 'w', encoding='utf-8') as pofile:
|
||||||
|
pofile.write(content)
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
|
Loading…
Reference in New Issue
Block a user