[20] | 1 | import wx |
---|
| 2 | import os |
---|
| 3 | import sys |
---|
| 4 | |
---|
| 5 | i = j = k= 0 |
---|
| 6 | f = open(sys.argv[1],'r') |
---|
| 7 | os.system("sudo rm -rf pofile") |
---|
| 8 | po = open(sys.argv[1]+'.po','w') |
---|
| 9 | po.write('msgid \"\"\n') |
---|
| 10 | po.write('msgstr \"\"\n') |
---|
| 11 | po.write('\"Project-Id-Version: PACKAGE VERSION\\n"\n') |
---|
| 12 | po.write('\"POT-Creation-Date: 2006-11-04 09:59+CST\\n"\n') |
---|
| 13 | po.write('\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"\n') |
---|
| 14 | po.write('\"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"\n') |
---|
| 15 | po.write('\"Language-Team: LANGUAGE <LL@li.org>\\n"\n') |
---|
| 16 | po.write('\"MIME-Version: 1.0\\n"\n') |
---|
| 17 | po.write('\"Content-Type: text/plain; charset=utf8\\n"\n') |
---|
| 18 | po.write('\"Content-Transfer-Encoding: cp936\\n"\n') |
---|
| 19 | po.write('\"Generated-By: pygettext.py 1.5\\n"\n\n') |
---|
| 20 | |
---|
| 21 | tokens2=[] |
---|
| 22 | # read the lang files under dir:/opt/drbl/lang/bash/ |
---|
| 23 | content = f.read() |
---|
| 24 | # read each lines, and saves everyline as a array element |
---|
| 25 | tokens = content.splitlines() |
---|
| 26 | |
---|
| 27 | for i in range(0,len(tokens)): |
---|
| 28 | tokens2.append(tokens[i].partition('=')[0]) |
---|
| 29 | tokens2.append(tokens[i].partition('=')[2]) |
---|
| 30 | |
---|
| 31 | for j in range(0,(2*(len(tokens)))): |
---|
| 32 | if tokens2[j].startswith('#')==1: |
---|
| 33 | tokens2[j] = '' |
---|
| 34 | elif tokens2[j].startswith(' ')==1: |
---|
| 35 | tokens2[j] = '' |
---|
| 36 | if tokens2[j] != '': |
---|
| 37 | if j == 0: |
---|
| 38 | po.write('msgid ') |
---|
| 39 | po.write('\'%s\'\n' % tokens2[0]) |
---|
| 40 | elif j == 1: |
---|
| 41 | po.write('msgstr ') |
---|
| 42 | po.write('%s\n\n' % tokens2[1]) |
---|
| 43 | elif j%2 == 0: |
---|
| 44 | po.write('msgid ') |
---|
| 45 | po.write('\'%s\'\n' % tokens2[j]) |
---|
| 46 | else: |
---|
| 47 | po.write('msgstr ') |
---|
| 48 | po.write('%s\n\n' % tokens2[j]) |
---|
| 49 | |
---|
| 50 | f.close() |
---|
| 51 | po.close() |
---|