1
2
3
4 from translate.convert import po2txt
5 from translate.convert import test_convert
6 from translate.misc import wStringIO
7
9 - def po2txt(self, posource, txttemplate=None):
21
23 """test basic conversion"""
24 txttemplate = "Heading\n\nBody text"
25 posource = 'msgid "Heading"\nmsgstr "Opskrif"\n\nmsgid "Body text"\nmsgstr "Lyfteks"\n'
26 assert self.po2txt(posource, txttemplate) == "Opskrif\n\nLyfteks"
27
29 """test conversion with non-ascii text"""
30 txttemplate = "Heading\n\nFile content"
31 posource = 'msgid "Heading"\nmsgstr "Opskrif"\n\nmsgid "File content"\nmsgstr "Lêerinhoud"\n'
32 assert self.po2txt(posource, txttemplate) == "Opskrif\n\nLêerinhoud"
33
35 """check that we discard blank messages"""
36 txttemplate = "Heading\n\nBody text"
37 posource = 'msgid "Heading"\nmsgstr "Opskrif"\n\nmsgid "Body text"\nmsgstr ""\n'
38 assert self.po2txt(posource) == "Opskrif\n\nBody text"
39 assert self.po2txt(posource, txttemplate) == "Opskrif\n\nBody text"
40
42 """check that we handle fuzzy message correctly"""
43 txttemplate = "Heading\n\nBody text"
44 posource = '#, fuzzy\nmsgid "Heading"\nmsgstr "Opskrif"\n\nmsgid "Body text"\nmsgstr "Lyfteks"\n'
45 assert self.po2txt(posource) == "Heading\n\nLyfteks"
46 assert self.po2txt(posource, txttemplate) == "Heading\n\nLyfteks"
47
49 """Tests running actual po2txt commands on files"""
50 convertmodule = po2txt
51 defaultoptions = {"progress": "none"}
52
61