diff --git a/CHANGES b/CHANGES
index bbf036276..ee1a0c722 100644
--- a/CHANGES
+++ b/CHANGES
@@ -19,6 +19,7 @@ Bugs fixed
* #4924: html search: Upper characters problem in any other languages
* #4932: apidoc: some subpackage is ignored if sibling subpackage contains a
module starting with underscore
+* #4913: i18n: literal blocks in bullet list are not translated
Testing
--------
diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py
index f439c515e..0285e4241 100644
--- a/sphinx/util/nodes.py
+++ b/sphinx/util/nodes.py
@@ -53,6 +53,10 @@ def apply_source_workaround(node):
node.rawsource = re.sub(r'\s*:\s*%s' % re.escape(classifier.astext()),
'', node.rawsource)
+ # workaround: literal_block under bullet list (#4913)
+ if isinstance(node, nodes.literal_block) and node.source is None:
+ node.source = find_source_node(node)
+
# workaround: recommonmark-0.2.0 doesn't set rawsource attribute
if not node.rawsource:
node.rawsource = node.astext()
diff --git a/tests/roots/test-intl/literalblock.po b/tests/roots/test-intl/literalblock.po
index 0f2ddc613..040295359 100644
--- a/tests/roots/test-intl/literalblock.po
+++ b/tests/roots/test-intl/literalblock.po
@@ -72,6 +72,11 @@ msgstr ""
" return 0;\n"
"}"
+msgid "literal-block\n"
+"in list"
+msgstr "LITERAL-BLOCK\n"
+"IN LIST"
+
msgid "doctest blocks"
msgstr "DOCTEST-BLOCKS"
diff --git a/tests/roots/test-intl/literalblock.txt b/tests/roots/test-intl/literalblock.txt
index 57041fe41..2b9eb8eb1 100644
--- a/tests/roots/test-intl/literalblock.txt
+++ b/tests/roots/test-intl/literalblock.txt
@@ -44,6 +44,11 @@ code blocks
}
+* ::
+
+ literal-block
+ in list
+
doctest blocks
==============
diff --git a/tests/test_intl.py b/tests/test_intl.py
index c8c5a69e9..e6f8108b3 100644
--- a/tests/test_intl.py
+++ b/tests/test_intl.py
@@ -1000,6 +1000,14 @@ def test_additional_targets_should_not_be_translated(app):
"""<stdio.h>""")
assert_count(expected_expr, result, 1)
+ # literal block in list item should not be translated
+ expected_expr = ("""literal"""
+ """-"""
+ """block\n"""
+ """in """
+ """list""")
+ assert_count(expected_expr, result, 1)
+
# doctest block should not be translated but be highlighted
expected_expr = (
""">>> """
@@ -1066,6 +1074,14 @@ def test_additional_targets_should_be_translated(app):
"""<STDIO.H>""")
assert_count(expected_expr, result, 1)
+ # literal block in list item should be translated
+ expected_expr = ("""LITERAL"""
+ """-"""
+ """BLOCK\n"""
+ """IN """
+ """LIST""")
+ assert_count(expected_expr, result, 1)
+
# doctest block should not be translated but be highlighted
expected_expr = (
""">>> """