Closes #940: Fix gettext does not extract figure caption.

This is docutils issue.
see also: https://sourceforge.net/tracker/?func=detail&aid=3599485&group_id=38414&atid=422032
This commit is contained in:
Takayuki Shimizukawa
2013-01-05 01:06:42 +09:00
parent 263d5b376f
commit ab6706e6ed
7 changed files with 67 additions and 0 deletions

View File

@@ -1,6 +1,8 @@
Release 1.2 (in development)
============================
* #940: Fix gettext does not extract figure caption.
* #1067: Improve the ordering of the JavaScript search results: matches in titles
come before matches in full text, and object results are better categorized.
Also implement a pluggable search scorer.

View File

@@ -52,6 +52,13 @@ def extract_messages(doctree):
node.line = definition_list_item.line - 1
node.rawsource = definition_list_item.\
rawsource.split("\n", 2)[0]
# workaround: nodes.caption doesn't have source, line.
# this issue was filed to Docutils tracker:
# https://sourceforge.net/tracker/?func=detail&aid=3599485&group_id=38414&atid=422032
if isinstance(node, nodes.caption) and not node.source:
node.source = node.parent.source
node.line = '' #need fix docutils to get `node.line`
if not node.source:
continue # built-in message
if isinstance(node, IGNORED_NODES):

View File

@@ -0,0 +1,29 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2012, foof
# This file is distributed under the same license as the foo package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: sphinx 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-01-04 7:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "i18n with figure caption"
msgstr "I18N WITH FIGURE CAPTION"
msgid "My caption of the figure"
msgstr "MY CAPTION OF THE FIGURE"
msgid "My description paragraph1 of the figure."
msgstr "MY DESCRIPTION PARAGRAPH1 OF THE FIGURE."
msgid "My description paragraph2 of the figure."
msgstr "MY DESCRIPTION PARAGRAPH2 OF THE FIGURE."

View File

@@ -0,0 +1,12 @@
:tocdepth: 2
i18n with figure caption
========================
.. figure:: i18n.png
My caption of the figure
My description paragraph1 of the figure.
My description paragraph2 of the figure.

BIN
tests/root/i18n/i18n.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@@ -7,3 +7,4 @@
refs_inconsistency
literalblock
definition_terms
figure_caption

View File

@@ -243,3 +243,19 @@ def test_i18n_definition_terms(app):
u"\n THE CORRESPONDING DEFINITION #2\n")
assert result == expect
@with_app(buildername='text',
confoverrides={'language': 'xx', 'locale_dirs': ['.'],
'gettext_compact': False})
def test_i18n_figure_caption(app):
# regression test for #940
app.builder.build(['i18n/figure_caption'])
result = (app.outdir / 'i18n' / 'figure_caption.txt').text(encoding='utf-8')
expect = (u"\nI18N WITH FIGURE CAPTION"
u"\n************************\n"
u"\n [image]MY CAPTION OF THE FIGURE\n"
u"\n MY DESCRIPTION PARAGRAPH1 OF THE FIGURE.\n"
u"\n MY DESCRIPTION PARAGRAPH2 OF THE FIGURE.\n")
assert result == expect