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 html2po 
31  from translate.convert import mozfunny2prop 
32  from translate.storage import xpi 
33  from translate.convert import convert 
34   
36      formats = {(None, "*"): ("*", convert.copytemplate), 
37              ("*", "*"): ("*", convert.copyinput), 
38              "*": ("*", convert.copyinput)} 
39       
40      converters = [("dtd", dtd2po.convertdtd), ("properties", prop2po.convertprop), ("xhtml", html2po.converthtml), ("html", html2po.converthtml), 
41              ("it", mozfunny2prop.it2po), ("ini", mozfunny2prop.ini2po), ("inc", mozfunny2prop.inc2po)] 
42      for format, converter in converters: 
43          formats[(format, format)] = (format + ".po", converter) 
44          formats[format] = (format + ".po", converter) 
45       
46      replacer = convert.Replacer("en-US", "${locale}") 
47      for replaceformat in ("js", "rdf", "manifest"): 
48          formats[(None, replaceformat)] = (replaceformat, replacer.searchreplacetemplate) 
49          formats[(replaceformat, replaceformat)] = (replaceformat, replacer.searchreplaceinput) 
50          formats[replaceformat] = (replaceformat, replacer.searchreplaceinput) 
51      parser = convert.ArchiveConvertOptionParser(formats, usetemplates=True, usepots=True, description=__doc__, archiveformats={"xpi": xpi.XpiFile}) 
52      parser.add_duplicates_option() 
53      parser.passthrough.append("pot") 
54      parser.run(argv) 
 55   
56   
57  if __name__ == '__main__': 
58      main() 
59