diff options
author | Claude Paroz <claude@2xlibre.net> | 2011-06-29 21:15:46 +0200 |
---|---|---|
committer | Claude Paroz <claude@2xlibre.net> | 2011-06-29 21:15:46 +0200 |
commit | 6411b09431eb72ed5426d40a0142e7479c486d3b (patch) | |
tree | 544b9412dc9d16d3195b7843968ed661c4c624c9 /itstool.in | |
parent | 187fcbe585560f128c7436e66f6b8e3a789a73b0 (diff) | |
download | itstool-6411b09431eb72ed5426d40a0142e7479c486d3b.tar.gz |
Fix placeholder translation when it contains sub-elements
Diffstat (limited to 'itstool.in')
-rwxr-xr-x | itstool.in | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -692,8 +692,13 @@ class Document (object): if child.type != 'element': continue if child.ns() is not None and child.ns().content == NS_BLANK: - repl = self.get_translated(msg.get_placeholder(child.name).node, translations) - child.replaceNode(repl) + ph_node = msg.get_placeholder(child.name).node + if self.has_child_elements(ph_node): + self.merge_translations(translations, None, ph_node) + child.replaceNode(ph_node) + else: + repl = self.get_translated(ph_node, translations) + child.replaceNode(repl) scan_node(child) scan_node(trnode) retnode = node.copyNode(2) @@ -802,6 +807,9 @@ class Document (object): def is_translation_unit (self, node): return self.get_its_within_text(node) != 'yes' + def has_child_elements(self, node): + return len([child for child in xml_child_iter(node) if child.type=='element']) + def get_preserve_space (self, node): if node.getSpacePreserve() == 1: return True |