summaryrefslogtreecommitdiff
path: root/update-pot
blob: e9b3fbcbdc20c2a310367ae8308adb23685bb566 (plain)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 
#!/bin/sh # -*- Mode: sh; indent-tabs-mode: t -*- set -e # 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" for canary in "$c1" "$c2" "$c3"; do	if ! grep -q "$canary" "$OUTPUT"; then echo "canary '$canary' not found, pot extraction broken" ls -lh "$OUTPUT" exit 1	fi done } HERE="$(readlink -f "$(dirname "$0")")" OUTPUT="$HERE/po/snappy.pot" if [ -n "$1" ]; then	OUTPUT="$1" fi # ensure we have our xgettext-go go install github.com/snapcore/snapd/i18n/xgettext-go # exclude vendor and _build subdir I18N_FILES="$(mktemp -d)/i18n.files" find "$HERE" -type d \( -name "vendor" -o -name "_build" \) -prune -o -name "*.go" -type f -print > "$I18N_FILES" # shellcheck disable=SC2064 trap "rm -rf $(dirname "$I18N_FILES")" EXIT "${GOPATH%%:*}/bin/xgettext-go" \ -f "$I18N_FILES" \ -o "$OUTPUT" \ --add-comments-tag=TRANSLATORS: \ --no-location \ --sort-output \ --package-name=snappy\ --msgid-bugs-address=snappy-devel@lists.ubuntu.com \ --keyword=i18n.G \ --keyword-plural=i18n.DG # check canary check_canaries sed -i 's/charset=CHARSET/charset=UTF-8/' "$OUTPUT" # we need the || true because of # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=891347 xgettext "$HERE"/data/polkit/*.policy \ -o "$OUTPUT" \ --its="$HERE/po/its/polkit.its" \ --no-location \ --package-name=snappy \ --msgid-bugs-address=snappy-devel@lists.ubuntu.com \ --join-existing || true check_canaries # language packs for p in "${HERE}"/po/*.po; do	lang=$(basename "$p" .po)	mkdir -p "$HERE/share/locale/$lang/LC_MESSAGES"	msgfmt -v -o "$HERE/share/locale/$lang/LC_MESSAGES/snappy.mo" "$p" done