1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """convert Mozilla .dtd and .properties files to Gettext PO localization files
23
24 See: http://translate.sourceforge.net/wiki/toolkit/moz2po for examples and
25 usage instructions
26 """
27
28 from translate.convert import dtd2po
29 from translate.convert import prop2po
30 from translate.convert import mozfunny2prop
31 from translate.storage import xpi
32 from translate.convert import convert
33
35 formats = {(None, "*"): ("*", convert.copytemplate),
36 ("*", "*"): ("*", convert.copyinput),
37 "*": ("*", convert.copyinput)}
38
39 converters = [("dtd", dtd2po.convertdtd), ("properties", prop2po.convertmozillaprop),
40 ("it", mozfunny2prop.it2po), ("ini", mozfunny2prop.ini2po), ("inc", mozfunny2prop.inc2po)]
41 for format, converter in converters:
42 formats[(format, format)] = (format + ".po", converter)
43 formats[format] = (format + ".po", converter)
44
45 replacer = convert.Replacer("en-US", "${locale}")
46 for replaceformat in ("js", "rdf", "manifest"):
47 formats[(None, replaceformat)] = (replaceformat, replacer.searchreplacetemplate)
48 formats[(replaceformat, replaceformat)] = (replaceformat, replacer.searchreplaceinput)
49 formats[replaceformat] = (replaceformat, replacer.searchreplaceinput)
50 parser = convert.ArchiveConvertOptionParser(formats, usetemplates=True, usepots=True, description=__doc__, archiveformats={"xpi": xpi.XpiFile})
51 parser.add_duplicates_option()
52 parser.passthrough.append("pot")
53 parser.run(argv)
54
55
56 if __name__ == '__main__':
57 main()
58