From 45b8f11c68a170af74106d33f3604b7cbb9734f3 Mon Sep 17 00:00:00 2001 From: yanmaani Date: Fri, 10 Dec 2021 12:00:00 +0000 Subject: [PATCH] build: refactor out locale generation into build_locale.sh --- contrib/build-linux/sdist/make_sdist.sh | 15 +++------------ contrib/build_locale.sh | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 12 deletions(-) create mode 100755 contrib/build_locale.sh diff --git a/contrib/build-linux/sdist/make_sdist.sh b/contrib/build-linux/sdist/make_sdist.sh index 5429ec74e..d05a8a414 100755 --- a/contrib/build-linux/sdist/make_sdist.sh +++ b/contrib/build-linux/sdist/make_sdist.sh @@ -6,7 +6,7 @@ PROJECT_ROOT="$(dirname "$(readlink -e "$0")")/../../.." CONTRIB="$PROJECT_ROOT/contrib" CONTRIB_SDIST="$CONTRIB/build-linux/sdist" DISTDIR="$PROJECT_ROOT/dist" -LOCALE="$PROJECT_ROOT/electrum/locale/" +LOCALE="$PROJECT_ROOT/electrum/locale" . "$CONTRIB"/build_tools_util.sh @@ -24,21 +24,12 @@ python3 -m pip install --upgrade pip git submodule update --init ( - cd "$CONTRIB/deterministic-build/electrum-locale/" - if ! which msgfmt > /dev/null 2>&1; then - echo "Please install gettext" - exit 1 - fi # We include both source (.po) and compiled (.mo) locale files in the source dist. # Maybe we should exclude the compiled locale files? see https://askubuntu.com/a/144139 # (also see MANIFEST.in) rm -rf "$LOCALE" - for i in ./locale/*; do - dir="$PROJECT_ROOT/electrum/$i/LC_MESSAGES" - mkdir -p "$dir" - msgfmt --output-file="$dir/electrum.mo" "$i/electrum.po" || true - cp $i/electrum.po "$PROJECT_ROOT/electrum/$i/electrum.po" - done + cp -r "$CONTRIB/deterministic-build/electrum-locale/locale/" "$LOCALE/" + "$CONTRIB/build_locale.sh" "$LOCALE" ) ( diff --git a/contrib/build_locale.sh b/contrib/build_locale.sh new file mode 100755 index 000000000..d3157cafc --- /dev/null +++ b/contrib/build_locale.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +if [ ! -d "$1" ]; then + echo "usage: $0 path/to/locale" + exit 1 +fi + +if ! which msgfmt > /dev/null 2>&1; then + echo "Please install gettext" + exit 1 +fi + +for i in "$1/"*; do + mkdir -p "$i/LC_MESSAGES" + (msgfmt --output-file="$i/LC_MESSAGES/electrum.mo" "$i/electrum.po" || true) +done