summaryrefslogtreecommitdiff
path: root/sphinx/transforms.py
diff options
context:
space:
mode:
authorTakayuki Shimizukawa <shimizukawa@gmail.com>2013-10-04 08:12:20 +0000
committerTakayuki Shimizukawa <shimizukawa@gmail.com>2013-10-04 08:12:20 +0000
commit313559116dc469e710ca8bff3457b949c1703fb4 (patch)
tree9a0ffc1f3d5351771c12b1c0669f1af42df091bd /sphinx/transforms.py
parent603a75d8d3e25417fc014a5098f377aa411b1bd8 (diff)
downloadsphinx-git-313559116dc469e710ca8bff3457b949c1703fb4.tar.gz
Backed out changeset cfe9e2d11003 refs #1265
Diffstat (limited to 'sphinx/transforms.py')
-rw-r--r--sphinx/transforms.py44
1 files changed, 6 insertions, 38 deletions
diff --git a/sphinx/transforms.py b/sphinx/transforms.py
index 37952dd6f..338d47392 100644
--- a/sphinx/transforms.py
+++ b/sphinx/transforms.py
@@ -20,11 +20,7 @@ from docutils.transforms.parts import ContentsFilter
from sphinx import addnodes
from sphinx.locale import _, init as init_locale
from sphinx.util import split_index_msg
-from sphinx.util.nodes import (
- traverse_translatable_target,
- traverse_translatable_index,
- extract_messages,
-)
+from sphinx.util.nodes import traverse_translatable_index, extract_messages
from sphinx.util.osutil import ustrftime, find_catalog
from sphinx.util.compat import docutils_version
from sphinx.util.pycompat import all
@@ -182,34 +178,6 @@ class Locale(Transform):
parser = RSTParser()
#phase1: replace reference ids with translated names
- for node, msg in traverse_translatable_target(self.document):
- msgstr = catalog.gettext(msg)
- # XXX add marker to untranslated parts
- if not msgstr or msgstr == msg or not msgstr.strip():
- # as-of-yet untranslated
- continue
-
- patch = new_document(source, settings)
- CustomLocaleReporter(node.source, node.line).set_reporter(patch)
- parser.parse(msgstr, patch)
- patch = patch[0]
-
- # XXX doctest and other block markup
- if not isinstance(patch, nodes.paragraph):
- continue # skip for now
-
- old_name = msg
- new_name = nodes.fully_normalize_name(patch.astext())
-
- if old_name in self.document.nameids:
- self.document.nameids[new_name] = (
- self.document.nameids[old_name])
- self.document.nametypes[new_name] = (
- self.document.nametypes[old_name])
- self.document.refnames[new_name] = (
- self.document.refnames[old_name])
-
- #phase2: replace reference ids with translated names
for node, msg in extract_messages(self.document):
msgstr = catalog.gettext(msg)
# XXX add marker to untranslated parts
@@ -266,9 +234,9 @@ class Locale(Transform):
# _id was not duplicated.
# remove old_name entry from document ids database
# to reuse original _id.
- self.document.nameids.pop(old_name, None) #supplemental
- self.document.nametypes.pop(old_name, None) #supplemental
- self.document.ids.pop(_id, None) # must remove
+ self.document.nameids.pop(old_name, None)
+ self.document.nametypes.pop(old_name, None)
+ self.document.ids.pop(_id, None)
# re-entry with new named section node.
self.document.note_implicit_target(
@@ -310,7 +278,7 @@ class Locale(Transform):
node['translated'] = True
- #phase3: translation
+ #phase2: translation
for node, msg in extract_messages(self.document):
if node.get('translated', False):
continue
@@ -454,7 +422,7 @@ class Locale(Transform):
node.children = patch.children
node['translated'] = True
- #phase4: Extract and translate messages for index entries.
+ # Extract and translate messages for index entries.
for node, entries in traverse_translatable_index(self.document):
new_entries = []
for type, msg, tid, main in entries: