mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #3370: the caption of code-block is not picked up for translation
This commit is contained in:
parent
cf2061dfad
commit
1a2488610d
2
CHANGES
2
CHANGES
@ -13,6 +13,8 @@ Features added
|
|||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
* #3370: the caption of code-block is not picked up for translation
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ def container_wrapper(directive, literal_node, caption):
|
|||||||
raise ValueError(parsed[0])
|
raise ValueError(parsed[0])
|
||||||
caption_node = nodes.caption(parsed[0].rawsource, '',
|
caption_node = nodes.caption(parsed[0].rawsource, '',
|
||||||
*parsed[0].children)
|
*parsed[0].children)
|
||||||
caption_node.source = parsed[0].source
|
caption_node.source = literal_node.source
|
||||||
caption_node.line = parsed[0].line
|
caption_node.line = literal_node.line
|
||||||
container_node += caption_node
|
container_node += caption_node
|
||||||
container_node += literal_node
|
container_node += literal_node
|
||||||
return container_node
|
return container_node
|
||||||
|
@ -28,6 +28,9 @@ msgstr "MISSING LITERAL BLOCK::"
|
|||||||
msgid "That's all."
|
msgid "That's all."
|
||||||
msgstr "THAT'S ALL."
|
msgstr "THAT'S ALL."
|
||||||
|
|
||||||
|
msgid "included raw.txt"
|
||||||
|
msgstr "INCLUDED RAW.TXT"
|
||||||
|
|
||||||
msgid "code blocks"
|
msgid "code blocks"
|
||||||
msgstr "CODE-BLOCKS"
|
msgstr "CODE-BLOCKS"
|
||||||
|
|
||||||
@ -40,6 +43,9 @@ msgstr ""
|
|||||||
" 'RESULT'\n"
|
" 'RESULT'\n"
|
||||||
"end"
|
"end"
|
||||||
|
|
||||||
|
msgid "example of C language"
|
||||||
|
msgstr "EXAMPLE OF C LANGUAGE"
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"#include <stdlib.h>\n"
|
"#include <stdlib.h>\n"
|
||||||
"int main(int argc, char** argv)\n"
|
"int main(int argc, char** argv)\n"
|
||||||
|
@ -12,6 +12,9 @@ Missing literal block::
|
|||||||
|
|
||||||
That's all.
|
That's all.
|
||||||
|
|
||||||
|
.. literalinclude:: raw.txt
|
||||||
|
:caption: included raw.txt
|
||||||
|
|
||||||
code blocks
|
code blocks
|
||||||
==============
|
==============
|
||||||
|
|
||||||
@ -32,6 +35,7 @@ code blocks
|
|||||||
}
|
}
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
:caption: example of C language
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
@ -452,6 +452,22 @@ def test_gettext_glossary_term_inconsistencies(app):
|
|||||||
assert expect_msg.id in [m.id for m in actual if m.id]
|
assert expect_msg.id in [m.id for m in actual if m.id]
|
||||||
|
|
||||||
|
|
||||||
|
@sphinx_intl
|
||||||
|
@pytest.mark.sphinx('gettext')
|
||||||
|
@pytest.mark.test_params(shared_result='test_intl_gettext')
|
||||||
|
def test_gettext_literalblock(app):
|
||||||
|
app.build()
|
||||||
|
# --- gettext builder always ignores ``only`` directive
|
||||||
|
expect = read_po(app.srcdir / 'literalblock.po')
|
||||||
|
actual = read_po(app.outdir / 'literalblock.pot')
|
||||||
|
for expect_msg in [m for m in expect if m.id]:
|
||||||
|
if len(expect_msg.id.splitlines()) == 1:
|
||||||
|
# compare tranlsations only labels
|
||||||
|
assert expect_msg.id in [m.id for m in actual if m.id]
|
||||||
|
else:
|
||||||
|
pass # skip code-blocks and literalblocks
|
||||||
|
|
||||||
|
|
||||||
@sphinx_intl
|
@sphinx_intl
|
||||||
@pytest.mark.sphinx('gettext')
|
@pytest.mark.sphinx('gettext')
|
||||||
@pytest.mark.test_params(shared_result='test_intl_gettext')
|
@pytest.mark.test_params(shared_result='test_intl_gettext')
|
||||||
|
Loading…
Reference in New Issue
Block a user