diff options
author | Jan Holesovsky <kendy@suse.cz> | 2011-01-18 16:20:19 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2011-01-18 16:20:19 +0100 |
commit | d30dcb911d5eccfdb71d4d97965045cc0b043072 (patch) | |
tree | a4d85527588b96f9a38dac2dccb6cf9fc34945de /helpcontent2/to-wiki | |
parent | 64eaa45f2b8e9998575165ab320861d84e72b8ea (diff) |
wikihelp: Translate also the content of tables and list items.
Diffstat (limited to 'helpcontent2/to-wiki')
-rwxr-xr-x | helpcontent2/to-wiki/wikiconv2.py | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/helpcontent2/to-wiki/wikiconv2.py b/helpcontent2/to-wiki/wikiconv2.py index e1057ec251..6f5f80761d 100755 --- a/helpcontent2/to-wiki/wikiconv2.py +++ b/helpcontent2/to-wiki/wikiconv2.py @@ -495,7 +495,7 @@ class TableCell(ElementBase): if parser.follow_embed: self.embed_href(parser, fname, id) elif name == 'paragraph': - self.parse_child(TableContentParagraph(attrs, self)) + parser.parse_localized_paragraph(TableContentParagraph(attrs, self), attrs, self) elif name == 'section': self.parse_child(Section(attrs, self)) else: @@ -546,7 +546,7 @@ class ListItem(ElementBase): if parser.follow_embed: self.embed_href(parser, fname, id) elif name == 'paragraph': - self.parse_child(ListItemParagraph(attrs, self)) + parser.parse_localized_paragraph(ListItemParagraph(attrs, self), attrs, self) else: self.unhandled_element(parser, name) @@ -1096,36 +1096,40 @@ class ParserBase: def get_variable(self, id): return self.head_obj.get_variable(id) - def parse_paragraph(self, attrs, obj): - ignore_this = False - try: - if attrs['role'] == 'heading' and int(attrs['level']) == 1 \ - and self.ignore_heading and self.follow_embed: - self.ignore_heading = False - ignore_this = True - except: - pass - + def parse_localized_paragraph(self, paragraph, attrs, obj): + localized_text = '' try: localized_text = get_localized_text(self.filename, attrs['id']) except: pass - if ignore_this: - obj.parse_child(Ignore(attrs, obj, 'paragraph')) - elif localized_text != '': + if localized_text != '': # parse the localized text - localized_para = Paragraph(attrs, obj) text = u'<?xml version="1.0" encoding="UTF-8"?><localized>' + localized_text + '</localized>' ParserBase(self.filename, self.follow_embed, self.embedding_app, \ self.current_app, self.wiki_page_name, \ - localized_para, text.encode('utf-8')) + paragraph, text.encode('utf-8')) # add it to the overall structure - obj.objects.append(localized_para) + obj.objects.append(paragraph) # and ignore the original text obj.parse_child(Ignore(attrs, obj, 'paragraph')) else: - obj.parse_child(Paragraph(attrs, obj)) + obj.parse_child(paragraph) + + def parse_paragraph(self, attrs, obj): + ignore_this = False + try: + if attrs['role'] == 'heading' and int(attrs['level']) == 1 \ + and self.ignore_heading and self.follow_embed: + self.ignore_heading = False + ignore_this = True + except: + pass + + if ignore_this: + obj.parse_child(Ignore(attrs, obj, 'paragraph')) + else: + self.parse_localized_paragraph(Paragraph(attrs, obj), attrs, obj) class XhpParser(ParserBase): def __init__(self, filename, follow_embed, embedding_app, wiki_page_name): |