import wx import os import sys i = j = 0 f = open(sys.argv[1],'r') os.system("sudo rm -rf pofile") po = open(sys.argv[1]+'.po','w') po.write('msgid \"\"\n') po.write('msgstr \"\"\n') po.write('\"Project-Id-Version: PACKAGE VERSION\\n"\n') po.write('\"POT-Creation-Date: 2006-11-04 09:59+CST\\n"\n') po.write('\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"\n') po.write('\"Last-Translator: FULL NAME \\n"\n') po.write('\"Language-Team: LANGUAGE \\n"\n') po.write('\"MIME-Version: 1.0\\n"\n') po.write('\"Content-Type: text/plain; charset=utf8\\n"\n') po.write('\"Content-Transfer-Encoding: cp936\\n"\n') po.write('\"Generated-By: pygettext.py 1.5\\n"\n\n') tokens2=[] content = f.read() tokens=('%s' % content).split('\n') #print tokens[548] #print len(tokens) for i in range(0,(len(tokens)-1)): tokens2.append(tokens[i].split('=')[0]) tokens2.append(tokens[i].split('=')[1]) for j in range(0,(2*(len(tokens)-1))): if j == 0: po.write('msgid ') po.write('\'%s\'\n' % tokens2[j]) elif j ==1: po.write('msgstr ') po.write('%s\n\n' % tokens2[j]) elif j%2 ==0: po.write('msgid ') po.write('\'%s\'\n' % tokens2[j]) else: po.write('msgstr ') po.write('%s\n\n' % tokens2[j]) f.close() po.close()