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
27
29
30 - def __init__(self, templatefile, inputstore, dialect="default"):
31 from translate.storage import ini
32 self.templatefile = templatefile
33 self.templatestore = ini.inifile(templatefile, dialect=dialect)
34 self.inputstore = inputstore
35
50
51
52 -def convertini(inputfile, outputfile, templatefile, includefuzzy=False, dialect="default"):
53 inputstore = factory.getobject(inputfile)
54 if templatefile is None:
55 raise ValueError("must have template file for ini files")
56 else:
57 convertor = reini(templatefile, inputstore, dialect)
58 outputstring = convertor.convertstore(includefuzzy)
59 outputfile.write(outputstring)
60 return 1
61
62
63 -def convertisl(inputfile, outputfile, templatefile, includefuzzy=False, dialect="inno"):
65
66
68
69 from translate.convert import convert
70 formats = {
71 ("po", "ini"): ("ini", convertini),
72 ("po", "isl"): ("isl", convertisl),
73 }
74 parser = convert.ConvertOptionParser(formats, usetemplates=True, description=__doc__)
75 parser.add_fuzzy_option()
76 parser.run(argv)
77
78
79 if __name__ == '__main__':
80 main()
81