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.misc import quote 
26  from translate.storage import factory 
27  from translate.storage import ini 
28   
31          self.templatefile = templatefile 
32          self.templatestore = ini.inifile(templatefile) 
33          self.inputdict = {} 
 34   
41   
43           
44          for unit in store.units: 
45              if includefuzzy or not unit.isfuzzy(): 
46                   
47                  for location in unit.getlocations(): 
48                      inistring = unit.target 
49                      if len(inistring.strip()) == 0: 
50                          inistring = unit.source 
51                      self.inputdict[location] = inistring 
 53 -def convertini(inputfile, outputfile, templatefile, includefuzzy=False): 
 54      inputstore = factory.getobject(inputfile) 
55      if templatefile is None: 
56          raise ValueError("must have template file for ini files") 
57      else: 
58          convertor = reini(templatefile) 
59      outputstring = convertor.convertstore(inputstore, includefuzzy) 
60      outputfile.write(outputstring) 
61      return 1 
 62   
64       
65      from translate.convert import convert 
66      formats = {("po", "ini"): ("ini", convertini)} 
67      parser = convert.ConvertOptionParser(formats, usetemplates=True, description=__doc__) 
68      parser.add_fuzzy_option() 
69      parser.run(argv) 
 70   
71  if __name__ == '__main__': 
72      main() 
73