Files
spotifast/.github/scripts/update-translations.sh
T
Carmine Paolino 8bd25261c9 Rename the app to Spotifast while preserving installation identities
Use Spotifast across the native app, commands, packages and documentation. Keep existing state, credential stores, protocol identities and package names; provide both command names and compatible updater payloads. Rename the guides with jekyll-redirect-from and prepare spotifast.rocks as the website domain. Keep product descriptions name-free.
2026-09-14 10:43:11 +02:00

32 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Requires GNU gettext tools with Rust support. Normal Cargo builds do not.
set -euo pipefail
cd "$(dirname "$0")/../.."
mode=${1:-update}
if [[ "$mode" != update && "$mode" != --check ]]; then
echo "Usage: $0 [--check]" >&2
exit 2
fi
translation_template=$(mktemp)
trap 'rm -f "$translation_template"' EXIT
xgettext --language=Rust --from-code=UTF-8 \
--keyword= --keyword=gettext:2 --keyword=ngettext:2,3 \
--add-comments=Translators: \
--flag=ngettext:2:rust-format --flag=ngettext:3:rust-format \
--package-name=Spotifast --copyright-holder='Spotifast contributors' \
--msgid-bugs-address='https://github.com/crmne/spotifast/issues/new?template=translation.yml' \
--files-from=assets/i18n/POTFILES --output="$translation_template"
if [[ "$mode" == --check ]]; then
# The extraction timestamp is the only nondeterministic header.
diff -u <(sed '/^"POT-Creation-Date:/d' assets/i18n/fastpotify.pot) \
<(sed '/^"POT-Creation-Date:/d' "$translation_template")
else
cp "$translation_template" assets/i18n/fastpotify.pot
for catalog in assets/i18n/*.po; do
msgmerge --update --backup=none "$catalog" assets/i18n/fastpotify.pot
done
fi
for catalog in assets/i18n/*.po; do
msgfmt --check --check-format --output-file=/dev/null "$catalog"
done