Home | Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 # 4 # Copyright 2009-2010 Zuza Software Foundation 5 # 6 # This file is part of translate. 7 # 8 # This program is free software; you can redistribute it and/or modify 9 # it under the terms of the GNU General Public License as published by 10 # the Free Software Foundation; either version 2 of the License, or 11 # (at your option) any later version. 12 # 13 # This program is distributed in the hope that it will be useful, 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 # GNU General Public License for more details. 17 # 18 # You should have received a copy of the GNU General Public License 19 # along with this program; if not, see <http://www.gnu.org/licenses/>. 20 # 21 # (c) 2009 Dominic König (dominic@nursix.org) 22 # 23 24 """convert GNU/gettext PO files to web2py translation dictionaries (.py)""" 25 26 from translate.storage import factory 27 2830 3355 5635 from StringIO import StringIO 36 str_obj = StringIO() 37 38 mydict = dict() 39 for unit in inputstore.units: 40 if unit.isheader(): 41 continue 42 if unit.istranslated() or (includefuzzy and unit.isfuzzy()): 43 mydict[unit.source] = unit.target 44 else: 45 mydict[unit.source] = unit.source 46 # The older convention is to prefix with "*** ": 47 #mydict[unit.source] = '*** ' + unit.source 48 49 str_obj.write('{\n') 50 for source_str in mydict: 51 str_obj.write("%s:%s,\n" % (repr(str(source_str)), repr(str(mydict[source_str])))) 52 str_obj.write('}\n') 53 str_obj.seek(0) 54 return str_obj58 inputstore = factory.getobject(inputfile) 59 convertor = po2pydict() 60 outputstring = convertor.convertstore(inputstore, includefuzzy) 61 outputfile.write(outputstring.read()) 62 return 163 6466 from translate.convert import convert 67 from translate.misc import stdiotell 68 import sys 69 sys.stdout = stdiotell.StdIOWrapper(sys.stdout) 70 formats = {("po", "py"): ("py", convertpy), ("po"): ("py", convertpy)} 71 parser = convert.ConvertOptionParser(formats, usetemplates=False, description=__doc__) 72 parser.add_fuzzy_option() 73 parser.run(argv)74 75 76 if __name__ == '__main__': 77 main() 78
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Nov 19 17:48:12 2010 | http://epydoc.sourceforge.net |