simplify setup.py using package_data
This commit is contained in:
@@ -18,11 +18,7 @@
|
||||
|
||||
import gettext, os
|
||||
|
||||
if os.path.exists('./locale'):
|
||||
LOCALE_DIR = './locale'
|
||||
else:
|
||||
LOCALE_DIR = '/usr/share/locale'
|
||||
|
||||
LOCALE_DIR = os.path.join(os.path.dirname(__file__), 'locale')
|
||||
language = gettext.translation('electrum', LOCALE_DIR, fallback = True)
|
||||
|
||||
|
||||
|
||||
63
lib/mki18n.py
Executable file
63
lib/mki18n.py
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/python
|
||||
from StringIO import StringIO
|
||||
import urllib2, os, zipfile, pycurl
|
||||
|
||||
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()
|
||||
|
||||
# Generate fresh translation template
|
||||
if not os.path.exists('locale'):
|
||||
os.mkdir('locale')
|
||||
|
||||
cmd = 'xgettext -s --no-wrap -f app.fil --output=locale/messages.pot'
|
||||
print 'Generate template'
|
||||
os.system(cmd)
|
||||
|
||||
# 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)
|
||||
@@ -26,7 +26,6 @@ import string
|
||||
import ecdsa
|
||||
import pbkdf2
|
||||
|
||||
import util
|
||||
from util import print_error
|
||||
from bitcoin import is_old_seed, is_new_seed
|
||||
import version
|
||||
@@ -104,7 +103,7 @@ class Mnemonic(object):
|
||||
lang = i18n.language.info().get('language', 'en')
|
||||
print_error('language', lang)
|
||||
filename = filenames.get(lang[0:2], 'english.txt')
|
||||
path = os.path.join(util.data_dir(), 'wordlist', filename)
|
||||
path = os.path.join(os.path.dirname(__file__), 'wordlist', filename)
|
||||
s = open(path,'r').read().strip()
|
||||
s = unicodedata.normalize('NFKD', s.decode('utf8'))
|
||||
lines = s.split('\n')
|
||||
|
||||
2048
lib/wordlist/english.txt
Normal file
2048
lib/wordlist/english.txt
Normal file
File diff suppressed because it is too large
Load Diff
2048
lib/wordlist/japanese.txt
Normal file
2048
lib/wordlist/japanese.txt
Normal file
File diff suppressed because it is too large
Load Diff
1654
lib/wordlist/portuguese.txt
Normal file
1654
lib/wordlist/portuguese.txt
Normal file
File diff suppressed because it is too large
Load Diff
2048
lib/wordlist/spanish.txt
Normal file
2048
lib/wordlist/spanish.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user