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 from translate.storage import ini
27
29 - def __init__(self, templatefile, dialect):
30 self.templatefile = templatefile
31 self.templatestore = ini.inifile(templatefile, dialect=dialect)
32 self.inputdict = {}
33
40
42
43 for unit in store.units:
44 if includefuzzy or not unit.isfuzzy():
45
46 for location in unit.getlocations():
47 inistring = unit.target
48 if len(inistring.strip()) == 0:
49 inistring = unit.source
50 self.inputdict[location] = inistring
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, dialect)
58 outputstring = convertor.convertstore(inputstore, includefuzzy)
59 outputfile.write(outputstring)
60 return 1
61
62 -def convertisl(inputfile, outputfile, templatefile, includefuzzy=False, dialect="inno"):
64
66
67 from translate.convert import convert
68 formats = {
69 ("po", "ini"): ("ini", convertini),
70 ("po", "isl"): ("isl", convertisl),
71 }
72 parser = convert.ConvertOptionParser(formats, usetemplates=True, description=__doc__)
73 parser.add_fuzzy_option()
74 parser.run(argv)
75
76 if __name__ == '__main__':
77 main()
78