source: drbl_ui/langs/trans_lang_to_po.py @ 152

Last change on this file since 152 was 20, checked in by chris, 17 years ago
File size: 1.4 KB
Line 
1import wx
2import os
3import sys
4
5i = j = k= 0
6f = open(sys.argv[1],'r')
7os.system("sudo rm -rf pofile")
8po = open(sys.argv[1]+'.po','w')
9po.write('msgid \"\"\n')
10po.write('msgstr \"\"\n')
11po.write('\"Project-Id-Version: PACKAGE VERSION\\n"\n')
12po.write('\"POT-Creation-Date: 2006-11-04 09:59+CST\\n"\n')
13po.write('\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"\n')
14po.write('\"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"\n')
15po.write('\"Language-Team: LANGUAGE <LL@li.org>\\n"\n')
16po.write('\"MIME-Version: 1.0\\n"\n')
17po.write('\"Content-Type: text/plain; charset=utf8\\n"\n')
18po.write('\"Content-Transfer-Encoding: cp936\\n"\n')
19po.write('\"Generated-By: pygettext.py 1.5\\n"\n\n')
20
21tokens2=[]
22# read the lang files under dir:/opt/drbl/lang/bash/
23content = f.read()
24# read each lines, and saves everyline as a array element
25tokens = content.splitlines()
26
27for i in range(0,len(tokens)):
28    tokens2.append(tokens[i].partition('=')[0])
29    tokens2.append(tokens[i].partition('=')[2])
30
31for 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
50f.close()
51po.close()
Note: See TracBrowser for help on using the repository browser.