1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """convert Gettext PO localization files to .ini files"""
24
25 from translate.storage import factory
26
28 - def __init__(self, templatefile, inputstore, dialect="default"):
29 from translate.storage import ini
30 self.templatefile = templatefile
31 self.templatestore = ini.inifile(templatefile, dialect=dialect)
32 self.inputstore = inputstore
33
48
49 -def convertini(inputfile, outputfile, templatefile, includefuzzy=False, dialect="default"):
50 inputstore = factory.getobject(inputfile)
51 if templatefile is None:
52 raise ValueError("must have template file for ini files")
53 else:
54 convertor = reini(templatefile, inputstore, dialect)
55 outputstring = convertor.convertstore(includefuzzy)
56 outputfile.write(outputstring)
57 return 1
58
59 -def convertisl(inputfile, outputfile, templatefile, includefuzzy=False, dialect="inno"):
61
63
64 from translate.convert import convert
65 formats = {
66 ("po", "ini"): ("ini", convertini),
67 ("po", "isl"): ("isl", convertisl),
68 }
69 parser = convert.ConvertOptionParser(formats, usetemplates=True, description=__doc__)
70 parser.add_fuzzy_option()
71 parser.run(argv)
72
73 if __name__ == '__main__':
74 main()
75