diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-08-21 22:15:50 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-09-01 17:58:24 +0900 |
commit | 9b00c31ee26c57998c07fc908666da32442a060d (patch) | |
tree | 74f1bc837bd76f3ce81a44bf19e90931106a7753 /sphinx/transforms.py | |
parent | c6e102999f591948d942797af69284761dd5a3fb (diff) | |
download | sphinx-git-9b00c31ee26c57998c07fc908666da32442a060d.tar.gz |
Fix #1734: Could not translate the caption of toctree directive
Diffstat (limited to 'sphinx/transforms.py')
-rw-r--r-- | sphinx/transforms.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sphinx/transforms.py b/sphinx/transforms.py index 7b09285a4..8792d8f11 100644 --- a/sphinx/transforms.py +++ b/sphinx/transforms.py @@ -238,6 +238,17 @@ def publish_msgstr(app, source, source_path, source_line, config, settings): return doc +class PreserveTranslatableMessages(Transform): + """ + Preserve original translatable messages befor translation + """ + default_priority = 10 # this MUST be invoked before Locale transform + + def apply(self): + for node in self.document.traverse(addnodes.translatable): + node.preserve_original_messages() + + class Locale(Transform): """ Replace translatable nodes with their translated doctree. @@ -384,6 +395,11 @@ class Locale(Transform): if not msgstr or msgstr == msg: # as-of-yet untranslated continue + # update translatable nodes + if isinstance(node, addnodes.translatable): + node.apply_translated_message(msg, msgstr) + continue + # Avoid "Literal block expected; none found." warnings. # If msgstr ends with '::' then it cause warning message at # parser.parse() processing. |