agama/web/build_pot
Martin Vidner 19056e3316 added rust/build_pot and refactored its friends
rust/build_pot is again very similar to web/build_pot except for the file
finding details, the language, and the (so far implicit) keywords.

Use `rust/build_pot --container` on older distros.
`web/build_pot_container` is now just a shortcut for
`web/build_pot --container`.

The inlined container logic relies on a `devel/xgettext/run.sh` helper which
calls `build.sh` before running its arguments.
2026-01-15 12:28:16 +01:00

60 lines
1.7 KiB
Bash
Executable file

#! /bin/sh
# This script builds the POT file with the translatable texts from the web UI.
# NOTE: The TSX input file format requires a newer version of the GNU gettext,
# for running in openSUSE Leap or in SLE use the --container switch
# which runs a newer gettext in an openSUSE Tumbleweed container.
# path to this script
DIR="$(dirname "$0")"
if [ "$1" = "--container" ]; then
shift
OUTPUT="${1:-agama.pot}"
# run the container script instead of the standard "xgettext" command
XGETTEXT=../devel/xgettext/xgettext.sh
exec "$DIR"/../devel/xgettext/run.sh "$0" "$OUTPUT" "$XGETTEXT"
fi
# always run in the directory of this script to ensure the file paths
# saved in the POT file are always the same
cd "$DIR" || exit
OUTPUT="${1:-agama.pot}"
XGETTEXT="${2:-xgettext}"
# In this complex invocation, the order of option is roughly
# from generic to specific.
# (putting this to a function enables putting the above comment close to the code,
# unlike in the pipeline)
call_xgettext() {
$XGETTEXT \
--files-from=- \
--output="$OUTPUT" \
--sort-by-file \
--from-code=UTF-8 \
--foreign-user --copyright-holder="SuSE Linux Products GmbH, Nuernberg" \
--add-comments=TRANSLATORS \
--default-domain=agama \
--language=tsx \
--keyword= --keyword=_:1 --keyword=N_:1 --keyword=n_:1,2 --keyword=Nn_:1,2
}
# Idea: find files of certain extensions
# but not those matching certain more specific patterns
find . \
! -name po-converter.js \
! -name '*.test.js' \
-name '*.js' \
-o \
! -name '*.test.jsx' \
-name '*.jsx' \
-o \
! -name '*.test.ts' \
-name '*.ts' \
-o \
! -name '*.test.tsx' \
-name '*.tsx' |
grep -vE "node_modules/|dist/|coverage/" | \
call_xgettext