@@ -64,7 +64,7 @@ task:
|
|||||||
fingerprint_script: echo Locale && echo $ELECTRUM_IMAGE && cat $ELECTRUM_REQUIREMENTS_CI
|
fingerprint_script: echo Locale && echo $ELECTRUM_IMAGE && cat $ELECTRUM_REQUIREMENTS_CI
|
||||||
install_script:
|
install_script:
|
||||||
- apt-get update
|
- apt-get update
|
||||||
- apt-get -y install gettext
|
- apt-get -y install gettext qttools5-dev-tools
|
||||||
- pip install -r $ELECTRUM_REQUIREMENTS_CI
|
- pip install -r $ELECTRUM_REQUIREMENTS_CI
|
||||||
- pip install requests
|
- pip install requests
|
||||||
locale_script:
|
locale_script:
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ $ python3 -m pip install --user -e .
|
|||||||
|
|
||||||
Create translations (optional):
|
Create translations (optional):
|
||||||
```
|
```
|
||||||
$ sudo apt-get install python-requests gettext qttools5-dev-tools
|
$ sudo apt-get install python3-requests gettext qttools5-dev-tools
|
||||||
$ ./contrib/pull_locale
|
$ ./contrib/pull_locale
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Submodule contrib/deterministic-build/electrum-locale updated: 4941c1a929...a87f9a0430
@@ -1,89 +1,21 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import io
|
import importlib.util
|
||||||
import zipfile
|
|
||||||
import sys
|
|
||||||
|
|
||||||
try:
|
project_root = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||||
import requests
|
locale_path = os.path.join(project_root, "electrum", "locale")
|
||||||
except ImportError as e:
|
|
||||||
sys.exit(f"Error: {str(e)}. Try 'sudo python3 -m pip install <module-name>'")
|
|
||||||
|
|
||||||
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
# download latest .po files from crowdin
|
||||||
os.chdir('..')
|
locale_update = os.path.join(project_root, "contrib", "deterministic-build", "electrum-locale", "update.py")
|
||||||
|
assert os.path.exists(locale_update)
|
||||||
|
# load update.py; needlessly complicated alternative to "imp.load_source":
|
||||||
|
lu_spec = importlib.util.spec_from_file_location('update', locale_update)
|
||||||
|
lu_module = importlib.util.module_from_spec(lu_spec)
|
||||||
|
lu_spec.loader.exec_module(lu_module)
|
||||||
|
|
||||||
cmd = "find electrum -type f -name '*.py' -o -name '*.kv'"
|
lu_module.pull_locale(locale_path)
|
||||||
|
|
||||||
files = subprocess.check_output(cmd, shell=True)
|
|
||||||
|
|
||||||
with open("app.fil", "wb") as f:
|
|
||||||
f.write(files)
|
|
||||||
|
|
||||||
print("Found {} files to translate".format(len(files.splitlines())))
|
|
||||||
|
|
||||||
# Generate fresh translation template
|
|
||||||
if not os.path.exists('electrum/locale'):
|
|
||||||
os.mkdir('electrum/locale')
|
|
||||||
cmd = 'xgettext -s --from-code UTF-8 --language Python --no-wrap -f app.fil --output=messages.pot'
|
|
||||||
print('Generate template')
|
|
||||||
os.system(cmd)
|
|
||||||
|
|
||||||
# add QML translations
|
|
||||||
cmd = "find electrum/gui/qml -type f -name '*.qml'"
|
|
||||||
|
|
||||||
files = subprocess.check_output(cmd, shell=True)
|
|
||||||
|
|
||||||
with open("qml.lst", "wb") as f:
|
|
||||||
f.write(files)
|
|
||||||
|
|
||||||
print("Found {} QML files to translate".format(len(files.splitlines())))
|
|
||||||
|
|
||||||
cmd = "lupdate @qml.lst -ts qml.ts"
|
|
||||||
print('Collecting strings')
|
|
||||||
os.system(cmd)
|
|
||||||
|
|
||||||
cmd = "lconvert -of po -o qml.pot qml.ts"
|
|
||||||
print('Convert to gettext')
|
|
||||||
os.system(cmd)
|
|
||||||
|
|
||||||
cmd = "msgcat -u -o electrum/locale/messages.pot messages.pot qml.pot"
|
|
||||||
print('Generate template')
|
|
||||||
os.system(cmd)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
os.chdir('electrum')
|
|
||||||
|
|
||||||
crowdin_identifier = 'electrum'
|
|
||||||
crowdin_file_name = 'files[electrum-client/messages.pot]'
|
|
||||||
locale_file_name = 'locale/messages.pot'
|
|
||||||
|
|
||||||
# Download & unzip
|
|
||||||
print('Download translations')
|
|
||||||
s = requests.request('GET', 'https://crowdin.com/backend/download/project/' + crowdin_identifier + '.zip').content
|
|
||||||
zfobj = zipfile.ZipFile(io.BytesIO(s))
|
|
||||||
|
|
||||||
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:
|
|
||||||
with open(name[16:], 'wb') as output:
|
|
||||||
output.write(zfobj.read(name))
|
|
||||||
|
|
||||||
# Convert .po to .mo
|
# Convert .po to .mo
|
||||||
print('Installing')
|
subprocess.check_output([f"{project_root}/contrib/build_locale.sh", locale_path, locale_path])
|
||||||
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)
|
|
||||||
|
|||||||
@@ -6,13 +6,14 @@ import sys
|
|||||||
try:
|
try:
|
||||||
import requests
|
import requests
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
sys.exit(f"Error: {str(e)}. Try 'sudo python3 -m pip install <module-name>'")
|
sys.exit(f"Error: {str(e)}. Try 'python3 -m pip install --user <module-name>'")
|
||||||
|
|
||||||
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
|
||||||
os.chdir('..')
|
project_root = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||||
|
|
||||||
|
os.chdir(project_root)
|
||||||
|
|
||||||
cmd = "find electrum -type f -name '*.py' -o -name '*.kv'"
|
cmd = "find electrum -type f -name '*.py' -o -name '*.kv'"
|
||||||
|
|
||||||
files = subprocess.check_output(cmd, shell=True)
|
files = subprocess.check_output(cmd, shell=True)
|
||||||
|
|
||||||
with open("app.fil", "wb") as f:
|
with open("app.fil", "wb") as f:
|
||||||
@@ -24,10 +25,33 @@ print("Found {} files to translate".format(len(files.splitlines())))
|
|||||||
if not os.path.exists('electrum/locale'):
|
if not os.path.exists('electrum/locale'):
|
||||||
os.mkdir('electrum/locale')
|
os.mkdir('electrum/locale')
|
||||||
print('Generating template...')
|
print('Generating template...')
|
||||||
cmd = 'xgettext -s --from-code UTF-8 --language Python --no-wrap -f app.fil --output=electrum/locale/messages.pot'
|
cmd = 'xgettext -s --from-code UTF-8 --language Python --no-wrap -f app.fil --output=messages.pot'
|
||||||
subprocess.check_output(cmd, shell=True)
|
subprocess.check_output(cmd, shell=True)
|
||||||
|
|
||||||
os.chdir('electrum')
|
|
||||||
|
# add QML translations
|
||||||
|
cmd = "find electrum/gui/qml -type f -name '*.qml'"
|
||||||
|
files = subprocess.check_output(cmd, shell=True)
|
||||||
|
|
||||||
|
with open("qml.lst", "wb") as f:
|
||||||
|
f.write(files)
|
||||||
|
|
||||||
|
print("Found {} QML files to translate".format(len(files.splitlines())))
|
||||||
|
|
||||||
|
cmd = "lupdate @qml.lst -ts qml.ts"
|
||||||
|
print('Collecting strings')
|
||||||
|
subprocess.check_output(cmd, shell=True)
|
||||||
|
|
||||||
|
cmd = "lconvert -of po -o qml.pot qml.ts"
|
||||||
|
print('Convert to gettext')
|
||||||
|
subprocess.check_output(cmd, shell=True)
|
||||||
|
|
||||||
|
cmd = "msgcat -u -o electrum/locale/messages.pot messages.pot qml.pot"
|
||||||
|
print('Generate template')
|
||||||
|
subprocess.check_output(cmd, shell=True)
|
||||||
|
|
||||||
|
|
||||||
|
os.chdir(os.path.join(project_root, "electrum"))
|
||||||
|
|
||||||
crowdin_api_key = None
|
crowdin_api_key = None
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#
|
#
|
||||||
# Note: steps before doing a new release:
|
# Note: steps before doing a new release:
|
||||||
# - update locale:
|
# - update locale:
|
||||||
# 1. cd /opt/electrum-locale && ./update && git push
|
# 1. cd /opt/electrum-locale && ./update.py && git push
|
||||||
# 2. cd to the submodule dir, and git pull
|
# 2. cd to the submodule dir, and git pull
|
||||||
# 3. cd .. && git push
|
# 3. cd .. && git push
|
||||||
# - update RELEASE-NOTES and version.py
|
# - update RELEASE-NOTES and version.py
|
||||||
|
|||||||
Reference in New Issue
Block a user