import wx import os import sys i = j = k= 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=[] # read the lang files under dir:/opt/drbl/lang/bash/ content = f.read() # read each lines, and saves everyline as a array element tokens = content.splitlines() for i in range(0,len(tokens)): tokens2.append(tokens[i].partition('=')[0]) tokens2.append(tokens[i].partition('=')[2]) for j in range(0,(2*(len(tokens)))): if tokens2[j].startswith('#')==1: tokens2[j] = '' elif tokens2[j].startswith(' ')==1: tokens2[j] = '' if tokens2[j] != '': if j == 0: po.write('msgid ') po.write('\'%s\'\n' % tokens2[0]) elif j == 1: po.write('msgstr ') po.write('%s\n\n' % tokens2[1]) 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()