Merge pull request #9726 from SomberNight/202504_locale
mv git submodule electrum-locale from contrib to electrum/locale
This commit is contained in:
@@ -6,7 +6,6 @@ CONTRIB_ANDROID="$(dirname "$(readlink -e "$0")")"
|
||||
CONTRIB="$CONTRIB_ANDROID"/..
|
||||
PROJECT_ROOT="$CONTRIB"/..
|
||||
PACKAGES="$PROJECT_ROOT"/packages/
|
||||
LOCALE="$PROJECT_ROOT"/electrum/locale/
|
||||
|
||||
. "$CONTRIB"/build_tools_util.sh
|
||||
|
||||
@@ -20,17 +19,12 @@ if [ ! -d "$PACKAGES" ]; then
|
||||
"$CONTRIB"/make_packages.sh || fail "make_packages failed"
|
||||
fi
|
||||
|
||||
pushd "$PROJECT_ROOT"
|
||||
git submodule update --init
|
||||
popd
|
||||
|
||||
# update locale
|
||||
info "preparing electrum-locale."
|
||||
(
|
||||
LOCALE="$PROJECT_ROOT/electrum/locale/"
|
||||
"$CONTRIB/locale/build_cleanlocale.sh"
|
||||
# we want the binary to have only compiled (.mo) locale files; not source (.po) files
|
||||
rm -rf "$LOCALE"
|
||||
"$CONTRIB/build_locale.sh" "$CONTRIB/deterministic-build/electrum-locale/locale/" "$LOCALE"
|
||||
rm -r "$PROJECT_ROOT/electrum/locale/locale"/*/electrum.po
|
||||
)
|
||||
|
||||
pushd "$CONTRIB_ANDROID"
|
||||
|
||||
@@ -136,13 +136,9 @@ break_legacy_easy_install
|
||||
|
||||
info "preparing electrum-locale."
|
||||
(
|
||||
cd "$PROJECT_ROOT"
|
||||
git submodule update --init
|
||||
|
||||
LOCALE="$PROJECT_ROOT/electrum/locale/"
|
||||
"$CONTRIB/locale/build_cleanlocale.sh"
|
||||
# we want the binary to have only compiled (.mo) locale files; not source (.po) files
|
||||
rm -rf "$LOCALE"
|
||||
"$CONTRIB/build_locale.sh" "$CONTRIB/deterministic-build/electrum-locale/locale/" "$LOCALE"
|
||||
rm -r "$PROJECT_ROOT/electrum/locale/locale"/*/electrum.po
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -52,6 +52,6 @@ The differences are as follows:
|
||||
found and used at runtime.
|
||||
- the normal tarball includes compiled (.mo) locale files, the source-only tarball does not.
|
||||
Both tarballs contain (.po) source locale files. If you are packaging for a Linux distro,
|
||||
you probably want to compile the .mo locale files yourself (see `contrib/build_locale.sh`).
|
||||
you probably want to compile the .mo locale files yourself (see `contrib/locale/build_locale.sh`).
|
||||
- the normal tarball includes generated `*_pb2.py` files. These are created
|
||||
using `protobuf-compiler` from `.proto` files (see `contrib/generate_payreqpb2.sh`)
|
||||
|
||||
@@ -7,7 +7,6 @@ CONTRIB="$PROJECT_ROOT/contrib"
|
||||
CONTRIB_SDIST="$CONTRIB/build-linux/sdist"
|
||||
DISTDIR="$PROJECT_ROOT/dist"
|
||||
BUILDDIR="$CONTRIB_SDIST/build"
|
||||
LOCALE="$PROJECT_ROOT/electrum/locale"
|
||||
|
||||
. "$CONTRIB"/build_tools_util.sh
|
||||
|
||||
@@ -25,16 +24,14 @@ if ([ "$OMIT_UNCLEAN_FILES" != 1 ]); then
|
||||
"$CONTRIB"/make_packages.sh || fail "make_packages failed"
|
||||
fi
|
||||
|
||||
git submodule update --init
|
||||
|
||||
info "preparing electrum-locale."
|
||||
(
|
||||
"$CONTRIB/locale/build_cleanlocale.sh"
|
||||
# By default, include both source (.po) and compiled (.mo) locale files in the source dist.
|
||||
# Set option OMIT_UNCLEAN_FILES=1 to exclude the compiled locale files
|
||||
# see https://askubuntu.com/a/144139 (also see MANIFEST.in)
|
||||
rm -rf "$LOCALE"
|
||||
cp -r "$CONTRIB/deterministic-build/electrum-locale/locale/" "$LOCALE/"
|
||||
if ([ "$OMIT_UNCLEAN_FILES" != 1 ]); then
|
||||
"$CONTRIB/build_locale.sh" "$LOCALE" "$LOCALE"
|
||||
if ([ "$OMIT_UNCLEAN_FILES" = 1 ]); then
|
||||
rm -r "$PROJECT_ROOT/electrum/locale/locale"/*/LC_MESSAGES/electrum.mo
|
||||
fi
|
||||
)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
NAME_ROOT=electrum
|
||||
PROJECT_ROOT="$WINEPREFIX/drive_c/electrum"
|
||||
|
||||
export PYTHONDONTWRITEBYTECODE=1 # don't create __pycache__/ folders with .pyc files
|
||||
|
||||
@@ -10,18 +11,17 @@ set -e
|
||||
|
||||
. "$CONTRIB"/build_tools_util.sh
|
||||
|
||||
pushd $WINEPREFIX/drive_c/electrum
|
||||
pushd "$PROJECT_ROOT"
|
||||
|
||||
VERSION=$(git describe --tags --dirty --always)
|
||||
info "Last commit: $VERSION"
|
||||
|
||||
# Load electrum-locale for this release
|
||||
git submodule update --init
|
||||
|
||||
LOCALE="$WINEPREFIX/drive_c/electrum/electrum/locale/"
|
||||
# we want the binary to have only compiled (.mo) locale files; not source (.po) files
|
||||
rm -rf "$LOCALE"
|
||||
"$CONTRIB/build_locale.sh" "$CONTRIB/deterministic-build/electrum-locale/locale/" "$LOCALE"
|
||||
info "preparing electrum-locale."
|
||||
(
|
||||
"$CONTRIB/locale/build_cleanlocale.sh"
|
||||
# we want the binary to have only compiled (.mo) locale files; not source (.po) files
|
||||
rm -r "$PROJECT_ROOT/electrum/locale/locale"/*/electrum.po
|
||||
)
|
||||
|
||||
find -exec touch -h -d '2000-11-11T11:11:11+00:00' {} +
|
||||
popd
|
||||
@@ -48,7 +48,7 @@ $WINE_PYTHON -m pip install --no-build-isolation --no-dependencies --no-warn-scr
|
||||
--no-binary :all: --only-binary cffi,cryptography,hidapi \
|
||||
--cache-dir "$WINE_PIP_CACHE_DIR" -r "$CONTRIB"/deterministic-build/requirements-hw.txt
|
||||
|
||||
pushd $WINEPREFIX/drive_c/electrum
|
||||
pushd "$PROJECT_ROOT"
|
||||
# see https://github.com/pypa/pip/issues/2195 -- pip makes a copy of the entire directory
|
||||
info "Pip installing Electrum. This might take a long time if the project folder is large."
|
||||
$WINE_PYTHON -m pip install --no-build-isolation --no-dependencies --no-warn-script-location .
|
||||
|
||||
Submodule contrib/deterministic-build/electrum-locale deleted from 39132e7722
16
contrib/locale/build_cleanlocale.sh
Executable file
16
contrib/locale/build_cleanlocale.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
CONTRIB_LOCALE="$(dirname "$(readlink -e "$0")")"
|
||||
CONTRIB="$CONTRIB_LOCALE"/..
|
||||
PROJECT_ROOT="$CONTRIB"/..
|
||||
|
||||
cd "$PROJECT_ROOT"
|
||||
git submodule update --init
|
||||
|
||||
LOCALE="$PROJECT_ROOT/electrum/locale/"
|
||||
cd "$LOCALE"
|
||||
git clean -ffxd
|
||||
git reset --hard
|
||||
"$CONTRIB_LOCALE/build_locale.sh" "$LOCALE/locale" "$LOCALE/locale"
|
||||
@@ -1,10 +1,13 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This script converts human-readable (.po) locale files to compiled (.mo) locale files.
|
||||
|
||||
set -e
|
||||
|
||||
if [[ ! -d "$1" || -z "$2" ]]; then
|
||||
echo "usage: $0 locale_source_dir locale_dest_dir"
|
||||
echo " The dirs can match, to build in place."
|
||||
# ^ note: these are the paths to the "inner" locale/ dir
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# This script extracts "raw" strings from the codebase,
|
||||
# and uploads them to crowdin, for the community to translate them.
|
||||
#
|
||||
# Dependencies:
|
||||
# $ sudo apt-get install python3-requests gettext qt6-l10n-tools
|
||||
|
||||
@@ -12,9 +16,13 @@ except ImportError as e:
|
||||
sys.exit(f"Error: {str(e)}. Try 'python3 -m pip install --user <module-name>'")
|
||||
|
||||
# set cwd
|
||||
project_root = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
project_root = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
||||
os.chdir(project_root)
|
||||
|
||||
locale_dir = os.path.join(project_root, "electrum", "locale")
|
||||
if not os.path.exists(os.path.join(locale_dir, "locale")):
|
||||
raise Exception(f"missing git submodule for locale? {locale_dir}")
|
||||
|
||||
# check dependencies are available
|
||||
try:
|
||||
subprocess.check_output(["xgettext", "--version"])
|
||||
@@ -46,33 +54,41 @@ with open("app.fil", "wb") as f:
|
||||
print("Found {} files to translate".format(len(files.splitlines())))
|
||||
|
||||
# Generate fresh translation template
|
||||
if not os.path.exists('electrum/locale'):
|
||||
os.mkdir('electrum/locale')
|
||||
build_dir = os.path.join(locale_dir, "build")
|
||||
if not os.path.exists(build_dir):
|
||||
os.mkdir(build_dir)
|
||||
print('Generating template...')
|
||||
cmd = 'xgettext -s --from-code UTF-8 --language Python --no-wrap -f app.fil --output=electrum/locale/messages_gettext.pot'
|
||||
subprocess.check_output(cmd, shell=True)
|
||||
cmd = ["xgettext", "-s", "--from-code", "UTF-8", "--language", "Python", "--no-wrap", "-f", "app.fil", f"--output={build_dir}/messages_gettext.pot"]
|
||||
subprocess.check_output(cmd)
|
||||
|
||||
|
||||
# add QML translations
|
||||
cmd = "find electrum/gui/qml -type f -name '*.qml'"
|
||||
files = subprocess.check_output(cmd, shell=True)
|
||||
|
||||
with open("electrum/locale/qml.lst", "wb") as f:
|
||||
with open(f"{build_dir}/qml.lst", "wb") as f:
|
||||
f.write(files)
|
||||
|
||||
print("Found {} QML files to translate".format(len(files.splitlines())))
|
||||
|
||||
cmd = [QT_LUPDATE, "@electrum/locale/qml.lst","-ts", "electrum/locale/qml.ts"]
|
||||
# note: lupdate writes relative paths into its output .ts file, relative to the .ts file itself :/
|
||||
cmd = [QT_LUPDATE, f"@{build_dir}/qml.lst","-ts", f"{build_dir}/qml.ts"]
|
||||
print('Collecting strings')
|
||||
subprocess.check_output(cmd)
|
||||
|
||||
cmd = [QT_LCONVERT, "-of", "po", "-o", "electrum/locale/messages_qml.pot", "electrum/locale/qml.ts"]
|
||||
cmd = [QT_LCONVERT, "-of", "po", "-o", f"{build_dir}/messages_qml.pot", f"{build_dir}/qml.ts"]
|
||||
print('Convert to gettext')
|
||||
subprocess.check_output(cmd)
|
||||
|
||||
cmd = "msgcat -u -o electrum/locale/messages.pot electrum/locale/messages_gettext.pot electrum/locale/messages_qml.pot"
|
||||
print("Fixing some paths in messages_qml.pot")
|
||||
# sed from " ../../gui/qml/"
|
||||
# to " electrum/gui/qml/"
|
||||
cmd = ["sed", "-i", r"s/ ..\/..\/gui\/qml\// electrum\/gui\/qml\//g", f"{build_dir}/messages_qml.pot"]
|
||||
subprocess.check_output(cmd)
|
||||
|
||||
cmd = ["msgcat", "-u", "-o", f"{build_dir}/messages.pot", f"{build_dir}/messages_gettext.pot", f"{build_dir}/messages_qml.pot"]
|
||||
print('Generate template')
|
||||
subprocess.check_output(cmd, shell=True)
|
||||
subprocess.check_output(cmd)
|
||||
|
||||
|
||||
# prepare uploading to crowdin
|
||||
@@ -91,7 +107,7 @@ if not crowdin_api_key:
|
||||
print('Found crowdin_api_key. Will push updated source-strings to crowdin.')
|
||||
|
||||
crowdin_project_id = 20482 # for "Electrum" project on crowdin
|
||||
locale_file_name = "locale/messages.pot"
|
||||
locale_file_name = os.path.join(build_dir, "messages.pot")
|
||||
crowdin_file_name = "messages.pot"
|
||||
crowdin_file_id = 68 # for "/electrum-client/messages.pot"
|
||||
global_headers = {"Authorization": "Bearer {}".format(crowdin_api_key)}
|
||||
@@ -128,18 +128,15 @@ pyinstaller --version
|
||||
|
||||
rm -rf ./dist
|
||||
|
||||
git submodule update --init
|
||||
|
||||
info "generating locale"
|
||||
info "preparing electrum-locale."
|
||||
(
|
||||
if ! which msgfmt > /dev/null 2>&1; then
|
||||
brew install gettext
|
||||
brew link --force gettext
|
||||
fi
|
||||
LOCALE="$PROJECT_ROOT/electrum/locale/"
|
||||
"$CONTRIB/locale/build_cleanlocale.sh"
|
||||
# we want the binary to have only compiled (.mo) locale files; not source (.po) files
|
||||
rm -rf "$LOCALE"
|
||||
"$CONTRIB/build_locale.sh" "$CONTRIB/deterministic-build/electrum-locale/locale/" "$LOCALE"
|
||||
rm -r "$PROJECT_ROOT/electrum/locale/locale"/*/electrum.po
|
||||
) || fail "failed generating locale"
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import subprocess
|
||||
import importlib.util
|
||||
|
||||
project_root = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
locale_path = os.path.join(project_root, "electrum", "locale")
|
||||
|
||||
# download latest .po files from crowdin
|
||||
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)
|
||||
|
||||
lu_module.pull_locale(locale_path)
|
||||
|
||||
# Convert .po to .mo
|
||||
subprocess.check_output([f"{project_root}/contrib/build_locale.sh", locale_path, locale_path])
|
||||
|
||||
Reference in New Issue
Block a user