2012-05-18 06:28:55 -07:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import urllib2, os
|
2012-06-12 04:43:59 -07:00
|
|
|
from lib.version import TRANSLATION_ID
|
2012-05-18 06:28:55 -07:00
|
|
|
|
2012-06-12 04:43:59 -07:00
|
|
|
url = "https://en.bitcoin.it/w/index.php?title=Electrum/Translation&oldid=%d&action=raw"%TRANSLATION_ID
|
2012-05-18 06:28:55 -07:00
|
|
|
f = urllib2.urlopen(url)
|
|
|
|
lines = f.readlines()
|
|
|
|
dicts = {}
|
|
|
|
message = None
|
2012-05-24 01:37:45 -07:00
|
|
|
num_m = 0
|
2012-05-18 06:28:55 -07:00
|
|
|
for line in lines:
|
|
|
|
l = line.strip()
|
|
|
|
if not l: continue
|
|
|
|
if l[0] != '*': continue
|
|
|
|
if l[0:2] == '**':
|
|
|
|
lang, translation = l.split(':')
|
|
|
|
lang = lang[2:]
|
|
|
|
if dicts.get(lang) is None: dicts[lang] = {}
|
2012-06-09 08:35:07 -07:00
|
|
|
dicts[lang][message] = translation.strip()
|
2012-05-18 06:28:55 -07:00
|
|
|
else:
|
|
|
|
message = l[1:]
|
2012-05-24 01:37:45 -07:00
|
|
|
num_m += 1
|
2012-05-18 06:28:55 -07:00
|
|
|
|
2012-05-24 01:10:45 -07:00
|
|
|
#print dicts
|
2012-05-18 06:28:55 -07:00
|
|
|
|
2012-05-18 08:16:42 -07:00
|
|
|
if not os.path.exists('locale'):
|
|
|
|
os.mkdir('locale')
|
|
|
|
|
2012-05-18 06:28:55 -07:00
|
|
|
|
|
|
|
cmd = 'xgettext -s --no-wrap -f app.fil --output=locale/messages.pot'
|
|
|
|
print cmd
|
|
|
|
os.system(cmd)
|
|
|
|
|
|
|
|
f = open('locale/messages.pot','r')
|
|
|
|
s = f.read()
|
|
|
|
f.close()
|
|
|
|
s = s.replace('CHARSET', 'utf-8')
|
|
|
|
|
|
|
|
for lang, strings in dicts.items():
|
|
|
|
ss = s[:]
|
2012-05-24 01:37:45 -07:00
|
|
|
print(lang + " :%d/%d"%(len(strings), num_m))
|
2012-05-18 06:28:55 -07:00
|
|
|
for k,v in strings.items():
|
|
|
|
ss = ss.replace("msgid \"%s\"\nmsgstr \"\""%k,"msgid \"%s\"\nmsgstr \"%s\""%(k,v))
|
|
|
|
f = open('locale/electrum_%s.po'%lang,'w')
|
|
|
|
f.write(ss)
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
if not os.path.exists('locale/'+lang):
|
|
|
|
os.mkdir('locale/'+lang)
|
|
|
|
|
|
|
|
mo_dir = "locale/%s/LC_MESSAGES" % lang
|
|
|
|
if not os.path.exists(mo_dir):
|
|
|
|
os.mkdir(mo_dir)
|
|
|
|
|
|
|
|
cmd = 'msgfmt --output-file="%s/electrum.mo" "locale/electrum_%s.po"' % (mo_dir,lang)
|
2012-05-24 01:37:45 -07:00
|
|
|
#print cmd
|
2012-05-18 06:28:55 -07:00
|
|
|
os.system(cmd)
|
|
|
|
|