Skip to content

Commit

Permalink
update-pot: include file names, and extract strings from desktop files
Browse files Browse the repository at this point in the history
  • Loading branch information
jhenstridge committed Nov 2, 2020
1 parent 92506a3 commit 1a4a65e
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions update-pot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- Mode: sh; indent-tabs-mode: t -*-

set -e
set -eu

# In LP#1758684 we got reports that the pot file generation
# is broken. To get to the bottom of this add checks here
Expand All @@ -25,24 +25,24 @@ check_canaries() {
HERE="$(readlink -f "$(dirname "$0")")"

OUTPUT="$HERE/po/snappy.pot"
if [ -n "$1" ]; then
if [ -n "${1:-}" ]; then
OUTPUT="$1"
fi

# ensure we have our xgettext-go
go install github.com/snapcore/snapd/i18n/xgettext-go

tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT

# exclude vendor and _build subdir
I18N_FILES="$(mktemp -d)/i18n.files"
find "$HERE" -type d \( -name "vendor" -o -name "_build" -o -name ".git" \) -prune -o -name "*.go" -type f -print > "$I18N_FILES"
# shellcheck disable=SC2064
trap "rm -rf $(dirname "$I18N_FILES")" EXIT
find "$HERE" -type d \( -name "vendor" -o -name "_build" -o -name ".git" \) -prune -o -name "*.go" -type f -printf "%P\n" > "$tmpdir/go.files"

"${GOPATH%%:*}/bin/xgettext-go" \
-f "$I18N_FILES" \
-f "$tmpdir/go.files" \
-D "$HERE" \
-o "$OUTPUT" \
--add-comments-tag=TRANSLATORS: \
--no-location \
--sort-output \
--package-name=snappy\
--msgid-bugs-address=snappy-devel@lists.ubuntu.com \
Expand All @@ -54,12 +54,26 @@ check_canaries

sed -i 's/charset=CHARSET/charset=UTF-8/' "$OUTPUT"

find "$HERE" -path "$HERE/data/desktop/*.desktop.in" -type f -printf "%P\n" > "$tmpdir/desktop.files"
xgettext \
-f "$tmpdir/desktop.files" \
-D "$HERE" \
-o "$OUTPUT" \
--language=Desktop \
--sort-output \
--package-name=snappy \
--msgid-bugs-address=snappy-devel@lists.ubuntu.com \
--join-existing

find "$HERE" -path "$HERE/data/polkit/*.policy" -type f -printf "%P\n" > "$tmpdir/polkit.files"
# we need the || true because of
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=891347
xgettext "$HERE"/data/polkit/*.policy \
xgettext \
-f "$tmpdir/polkit.files" \
-D "$HERE" \
-o "$OUTPUT" \
--its="$HERE/po/its/polkit.its" \
--no-location \
--sort-output \
--package-name=snappy \
--msgid-bugs-address=snappy-devel@lists.ubuntu.com \
--join-existing || true
Expand Down

0 comments on commit 1a4a65e

Please sign in to comment.