gitee.com/mysnapcore/mysnapd@v0.1.0/update-pot (about) 1 #!/bin/sh 2 # -*- Mode: sh; indent-tabs-mode: t -*- 3 4 set -eu 5 6 # In LP#1758684 we got reports that the pot file generation 7 # is broken. To get to the bottom of this add checks here 8 # so that we error the build if this happens. Note that the 9 # strings may be update if those change but spread tests will 10 # tell us when it is needed. 11 check_canaries() { 12 c1="Alternative command to run" 13 c2="Name of the key to use, otherwise use the default key" 14 c3="too many arguments for command" 15 c4="%d days ago, at 15:04 MST" 16 17 for canary in "$c1" "$c2" "$c3" "$c4"; do 18 if ! grep -q "$canary" "$OUTPUT"; then 19 echo "canary '$canary' not found, pot extraction broken" 20 ls -lh "$OUTPUT" 21 exit 1 22 fi 23 done 24 } 25 26 HERE="$(readlink -f "$(dirname "$0")")" 27 28 OUTPUT="$HERE/po/snappy.pot" 29 if [ -n "${1:-}" ]; then 30 OUTPUT="$1" 31 fi 32 33 # ensure we have our xgettext-go 34 # shellcheck disable=SC2086 35 go install $GOINVOKEFLAGS gitee.com/mysnapcore/mysnapd/i18n/xgettext-go 36 37 tmpdir="$(mktemp -d)" 38 trap 'rm -rf "$tmpdir"' EXIT 39 40 # exclude vendor and _build subdir 41 find "$HERE" -type d \( -name "vendor" -o -name "_build" -o -name ".git" \) -prune -o -name "*.go" -type f -printf "%P\n" > "$tmpdir/go.files" 42 43 "${GOPATH%%:*}/bin/xgettext-go" \ 44 -f "$tmpdir/go.files" \ 45 -D "$HERE" \ 46 -o "$OUTPUT" \ 47 --add-comments-tag=TRANSLATORS: \ 48 --sort-output \ 49 --package-name=snappy\ 50 --msgid-bugs-address=snappy-devel@lists.ubuntu.com \ 51 --keyword=i18n.G \ 52 --keyword-plural=i18n.NG 53 54 # check canary 55 check_canaries 56 57 sed -i 's/charset=CHARSET/charset=UTF-8/' "$OUTPUT" 58 59 find "$HERE" -path "$HERE/data/desktop/*.desktop.in" -type f -printf "%P\n" > "$tmpdir/desktop.files" 60 # we need the || true because Ubuntu 14.04's xgettext does not support 61 # extracting from desktop files. 62 xgettext \ 63 -f "$tmpdir/desktop.files" \ 64 -D "$HERE" \ 65 -o "$OUTPUT" \ 66 --language=Desktop \ 67 --sort-output \ 68 --package-name=snappy \ 69 --msgid-bugs-address=snappy-devel@lists.ubuntu.com \ 70 --join-existing || true 71 72 find "$HERE" -path "$HERE/data/polkit/*.policy" -type f -printf "%P\n" > "$tmpdir/polkit.files" 73 # we need the || true because of 74 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=891347 75 xgettext \ 76 -f "$tmpdir/polkit.files" \ 77 -D "$HERE" \ 78 -o "$OUTPUT" \ 79 --its="$HERE/po/its/polkit.its" \ 80 --sort-output \ 81 --package-name=snappy \ 82 --msgid-bugs-address=snappy-devel@lists.ubuntu.com \ 83 --join-existing || true 84 85 check_canaries 86 87 # language packs 88 for p in "${HERE}"/po/*.po; do 89 lang=$(basename "$p" .po) 90 mkdir -p "$HERE/share/locale/$lang/LC_MESSAGES" 91 msgfmt -v -o "$HERE/share/locale/$lang/LC_MESSAGES/snappy.mo" "$p" 92 done