electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 91ea2d8752bd61905ed0acdfccebcf1daadf4e92
parent 1f586739152a5203fdaf206b7589b9de3d8f5422
Author: ThomasV <thomasv@gitorious>
Date:   Sat, 21 Feb 2015 12:41:52 +0100

move mki18n to contrib directory

Diffstat:
Acontrib/mki18n.py | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+), 0 deletions(-)

diff --git a/contrib/mki18n.py b/contrib/mki18n.py @@ -0,0 +1,64 @@ +#!/usr/bin/python +from StringIO import StringIO +import urllib2, os, zipfile, pycurl + +os.chdir(os.path.dirname(os.path.realpath(__file__))) +os.chdir('..') + +# Generate fresh translation template +if not os.path.exists('lib/locale'): + os.mkdir('lib/locale') +cmd = 'xgettext -s --no-wrap -f app.fil --output=lib/locale/messages.pot' +print 'Generate template' +os.system(cmd) + +os.chdir('lib') + +crowdin_identifier = 'electrum' +crowdin_file_name = 'electrum-client/messages.pot' +locale_file_name = 'locale/messages.pot' + +if os.path.exists('../contrib/crowdin_api_key.txt'): + crowdin_api_key = open('../contrib/crowdin_api_key.txt').read().strip() + # Push to Crowdin + print 'Push to Crowdin' + url = ('http://api.crowdin.net/api/project/' + crowdin_identifier + '/update-file?key=' + crowdin_api_key) + c = pycurl.Curl() + c.setopt(c.URL, url) + c.setopt(c.POST, 1) + fields = [('files[' + crowdin_file_name + ']', (pycurl.FORM_FILE, locale_file_name))] + c.setopt(c.HTTPPOST, fields) + c.perform() + # Build translations + print 'Build translations' + response = urllib2.urlopen('http://api.crowdin.net/api/project/' + crowdin_identifier + '/export?key=' + crowdin_api_key).read() + print response + +# Download & unzip +print 'Download translations' +zfobj = zipfile.ZipFile(StringIO(urllib2.urlopen('http://crowdin.net/download/project/' + crowdin_identifier + '.zip').read())) + +print 'Unzip translations' +for name in zfobj.namelist(): + if not name.startswith('electrum-client/locale'): + continue + if name.endswith('/'): + if not os.path.exists(name[16:]): + os.mkdir(name[16:]) + else: + output = open(name[16:],'w') + output.write(zfobj.read(name)) + output.close() + +# Convert .po to .mo +print 'Installing' +for lang in os.listdir('locale'): + if lang.startswith('messages'): + continue + # Check LC_MESSAGES folder + 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/%s/electrum.po"' % (mo_dir,lang) + print 'Installing',lang + os.system(cmd)