2015-06-16 09:13:22 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
# -*- Mode: sh; indent-tabs-mode: t -*-
|
|
|
|
|
|
2020-11-02 13:43:21 +08:00
|
|
|
set -eu
|
2015-06-16 09:13:22 +02:00
|
|
|
|
2018-06-26 17:56:02 +02:00
|
|
|
# In LP#1758684 we got reports that the pot file generation
|
|
|
|
|
# is broken. To get to the bottom of this add checks here
|
|
|
|
|
# so that we error the build if this happens. Note that the
|
|
|
|
|
# strings may be update if those change but spread tests will
|
|
|
|
|
# tell us when it is needed.
|
|
|
|
|
check_canaries() {
|
|
|
|
|
c1="Alternative command to run"
|
|
|
|
|
c2="Name of the key to use, otherwise use the default key"
|
|
|
|
|
c3="too many arguments for command"
|
2020-11-27 13:48:38 +08:00
|
|
|
c4="%d days ago, at 15:04 MST"
|
2018-06-26 17:56:02 +02:00
|
|
|
|
2020-11-27 13:48:38 +08:00
|
|
|
for canary in "$c1" "$c2" "$c3" "$c4"; do
|
2018-06-26 17:56:02 +02:00
|
|
|
if ! grep -q "$canary" "$OUTPUT"; then
|
|
|
|
|
echo "canary '$canary' not found, pot extraction broken"
|
2018-06-26 21:41:05 +02:00
|
|
|
ls -lh "$OUTPUT"
|
2018-06-26 17:56:02 +02:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-03 16:37:33 +02:00
|
|
|
HERE="$(readlink -f "$(dirname "$0")")"
|
2015-06-16 09:13:22 +02:00
|
|
|
|
|
|
|
|
OUTPUT="$HERE/po/snappy.pot"
|
2020-11-02 13:43:21 +08:00
|
|
|
if [ -n "${1:-}" ]; then
|
2015-06-16 09:13:22 +02:00
|
|
|
OUTPUT="$1"
|
|
|
|
|
fi
|
|
|
|
|
|
2015-08-14 23:12:29 +02:00
|
|
|
# ensure we have our xgettext-go
|
2021-09-09 13:39:11 +02:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
go install $GOINVOKEFLAGS github.com/snapcore/snapd/i18n/xgettext-go
|
2015-07-02 14:25:19 +02:00
|
|
|
|
2020-11-02 13:43:21 +08:00
|
|
|
tmpdir="$(mktemp -d)"
|
|
|
|
|
trap 'rm -rf "$tmpdir"' EXIT
|
|
|
|
|
|
2018-06-26 22:21:57 +02:00
|
|
|
# exclude vendor and _build subdir
|
2020-11-02 13:43:21 +08:00
|
|
|
find "$HERE" -type d \( -name "vendor" -o -name "_build" -o -name ".git" \) -prune -o -name "*.go" -type f -printf "%P\n" > "$tmpdir/go.files"
|
2018-06-27 08:34:02 +02:00
|
|
|
|
|
|
|
|
"${GOPATH%%:*}/bin/xgettext-go" \
|
2020-11-02 13:43:21 +08:00
|
|
|
-f "$tmpdir/go.files" \
|
|
|
|
|
-D "$HERE" \
|
2015-07-09 10:36:17 +02:00
|
|
|
-o "$OUTPUT" \
|
|
|
|
|
--add-comments-tag=TRANSLATORS: \
|
|
|
|
|
--sort-output \
|
|
|
|
|
--package-name=snappy\
|
|
|
|
|
--msgid-bugs-address=snappy-devel@lists.ubuntu.com \
|
|
|
|
|
--keyword=i18n.G \
|
2020-11-27 13:48:38 +08:00
|
|
|
--keyword-plural=i18n.NG
|
2015-07-02 14:25:19 +02:00
|
|
|
|
2018-06-26 17:56:02 +02:00
|
|
|
# check canary
|
|
|
|
|
check_canaries
|
|
|
|
|
|
2018-03-20 16:11:46 +01:00
|
|
|
sed -i 's/charset=CHARSET/charset=UTF-8/' "$OUTPUT"
|
|
|
|
|
|
2020-11-02 13:43:21 +08:00
|
|
|
find "$HERE" -path "$HERE/data/desktop/*.desktop.in" -type f -printf "%P\n" > "$tmpdir/desktop.files"
|
2020-11-02 22:14:00 +08:00
|
|
|
# we need the || true because Ubuntu 14.04's xgettext does not support
|
|
|
|
|
# extracting from desktop files.
|
2020-11-02 13:43:21 +08:00
|
|
|
xgettext \
|
|
|
|
|
-f "$tmpdir/desktop.files" \
|
|
|
|
|
-D "$HERE" \
|
|
|
|
|
-o "$OUTPUT" \
|
|
|
|
|
--language=Desktop \
|
|
|
|
|
--sort-output \
|
|
|
|
|
--package-name=snappy \
|
|
|
|
|
--msgid-bugs-address=snappy-devel@lists.ubuntu.com \
|
2020-11-02 22:14:00 +08:00
|
|
|
--join-existing || true
|
2020-11-02 13:43:21 +08:00
|
|
|
|
|
|
|
|
find "$HERE" -path "$HERE/data/polkit/*.policy" -type f -printf "%P\n" > "$tmpdir/polkit.files"
|
2018-06-26 18:43:07 +02:00
|
|
|
# we need the || true because of
|
|
|
|
|
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=891347
|
2020-11-02 13:43:21 +08:00
|
|
|
xgettext \
|
|
|
|
|
-f "$tmpdir/polkit.files" \
|
|
|
|
|
-D "$HERE" \
|
2018-02-22 17:37:57 +01:00
|
|
|
-o "$OUTPUT" \
|
2018-02-26 18:56:46 +01:00
|
|
|
--its="$HERE/po/its/polkit.its" \
|
2020-11-02 13:43:21 +08:00
|
|
|
--sort-output \
|
2018-02-22 17:37:57 +01:00
|
|
|
--package-name=snappy \
|
|
|
|
|
--msgid-bugs-address=snappy-devel@lists.ubuntu.com \
|
2018-06-26 18:43:07 +02:00
|
|
|
--join-existing || true
|
2018-02-22 17:37:57 +01:00
|
|
|
|
2018-06-26 17:56:02 +02:00
|
|
|
check_canaries
|
2015-06-16 09:13:22 +02:00
|
|
|
|
|
|
|
|
# language packs
|
2018-07-03 16:37:33 +02:00
|
|
|
for p in "${HERE}"/po/*.po; do
|
2017-05-22 17:40:43 +01:00
|
|
|
lang=$(basename "$p" .po)
|
|
|
|
|
mkdir -p "$HERE/share/locale/$lang/LC_MESSAGES"
|
|
|
|
|
msgfmt -v -o "$HERE/share/locale/$lang/LC_MESSAGES/snappy.mo" "$p"
|
2015-06-16 09:13:22 +02:00
|
|
|
done
|