diff options
author | Timo Richter <timo@iera.de> | 2011-08-26 13:29:27 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2011-08-26 13:30:51 +0200 |
commit | e56dbe6b95f14f9e4d3a416ea567b550fc9b79ed (patch) | |
tree | 6511a8aae332213778a297dc06f8183ea3dd7d88 /helpcontent2/wiki-to-help/metabook_translated.py | |
parent | 260b7c155537741fd6100eb88090b649c9904f02 (diff) |
License update. Implemented metabook generator.
mwlib modification: Base url to wiki is definable in nfo.json
mwlib modification: Implemented function that creates an article link
Created new docbook grammar for mwlib
Input test2.xml now contains one internal link in Mainpage > Writer/Welcome
Diffstat (limited to 'helpcontent2/wiki-to-help/metabook_translated.py')
-rw-r--r-- | helpcontent2/wiki-to-help/metabook_translated.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/helpcontent2/wiki-to-help/metabook_translated.py b/helpcontent2/wiki-to-help/metabook_translated.py new file mode 100644 index 0000000000..07364dd0d4 --- /dev/null +++ b/helpcontent2/wiki-to-help/metabook_translated.py @@ -0,0 +1,55 @@ +import metabook +import re + +class ArticleTranslated(metabook.Article): + lang = "en" # default language code + trans = "" # translated title + + def __init__(self,attributes): + title = attributes["title"] + parts = title.split("/") + #if len(parts) < 2: + # self.include = False + # return + if len(parts) == 1: + # title = "blabla" + self.title = title + if len(parts) == 2: + # title = "Category/englishTitle" + self.title = parts[1] + if len(parts) == 3: + # title = "Category/englishTitle/langCode" + self.lang = parts[2] + self.title = parts[1] + + comment = attributes["comment"] + if '{Lang|' in comment: + # Language-tag exists + r = re.search("\{Lang\|([^\}]*)\}",comment) + trans = r.group(1) + self.trans = trans + else: + self.trans = self.title + + attr = {} + attr["title"] = attributes["title"] + attr["displaytitle"] = self.trans + attr["lang"] = self.lang + self.attributes = attr + +class MetabookTranslated(metabook.Metabook): + """ + This concrete metabook expects article titles in this form: + Category/Title/lang + Comments include this: + {{Lang|translatedTitle}} + """ + ArticleClass=ArticleTranslated + artTags = ["title","comment"] + + def splitByLanguage(self): + """ + @return List of Metabook + """ + pass + |