Home | Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 # 4 # Copyright 2009 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 27315133 from StringIO import StringIO 34 str_obj = StringIO() 35 36 mydict = dict() 37 for unit in inputstore.units: 38 if unit.isheader(): 39 continue 40 if unit.istranslated() or (includefuzzy and unit.isfuzzy()): 41 mydict[unit.source] = unit.target 42 else: 43 mydict[unit.source] = '*** ' + unit.source 44 45 str_obj.write('{\n') 46 for source_str in mydict: 47 str_obj.write("%s:%s,\n" % (repr(str(source_str)),repr(str(mydict[source_str])))) 48 str_obj.write('}\n') 49 str_obj.seek(0) 50 return str_obj53 inputstore = factory.getobject(inputfile) 54 convertor = po2pydict() 55 outputstring = convertor.convertstore(inputstore, includefuzzy) 56 outputfile.write(outputstring.read()) 57 return 15860 from translate.convert import convert 61 from translate.misc import stdiotell 62 import sys 63 sys.stdout = stdiotell.StdIOWrapper(sys.stdout) 64 formats = {("po", "py"):("py", convertpy), ("po"):("py", convertpy)} 65 parser = convert.ConvertOptionParser(formats, usetemplates=False, description=__doc__) 66 parser.add_fuzzy_option() 67 parser.run(argv)68 69 if __name__ == '__main__': 70 main() 71
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Oct 15 13:55:54 2009 | http://epydoc.sourceforge.net |