summaryrefslogtreecommitdiff
path: root/sphinx
diff options
context:
space:
mode:
authorshimizukawa <shimizukawa@gmail.com>2013-02-05 12:47:08 +0900
committershimizukawa <shimizukawa@gmail.com>2013-02-05 12:47:08 +0900
commitb7e6f092216663c7829bbb20eb80d6a5ce407064 (patch)
tree5731407870b887248d8bb4bd46cc412c6d0cf16a /sphinx
parentbd942df4f41830a9b7de1f21f2c187fd971de85d (diff)
downloadsphinx-b7e6f092216663c7829bbb20eb80d6a5ce407064.tar.gz
fix: roles' reftarget ware swapped if there are some roles in 1 line and translation exchange rthat roles position. refs #1090
Diffstat (limited to 'sphinx')
-rw-r--r--sphinx/transforms.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/sphinx/transforms.py b/sphinx/transforms.py
index 43ec97cb..845b17ac 100644
--- a/sphinx/transforms.py
+++ b/sphinx/transforms.py
@@ -255,13 +255,20 @@ class Locale(Transform):
# Original pending_xref['reftarget'] contain not-translated
# target name, new pending_xref must use original one.
+ # This code restricts to change ref-targets in the translation.
old_refs = node.traverse(addnodes.pending_xref)
new_refs = patch.traverse(addnodes.pending_xref)
+ xref_reftarget_map = {}
if len(old_refs) != len(new_refs):
env.warn_node('inconsistent term references in '
'translated message', node)
- for old, new in zip(old_refs, new_refs):
- new['reftarget'] = old['reftarget']
+ for old in old_refs:
+ key = old["reftype"], old["refdomain"]
+ xref_reftarget_map[key] = old["reftarget"]
+ for new in new_refs:
+ key = new["reftype"], new["refdomain"]
+ if key in xref_reftarget_map:
+ new['reftarget'] = xref_reftarget_map[key]
# update leaves
for child in patch.children: