gds-render/translations/pot/prepare_language.sh

35 lines
920 B
Bash
Raw Permalink Normal View History

2019-10-18 20:34:03 +02:00
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )"
cd "$DIR"
2019-10-18 21:19:29 +02:00
if [ -z $1 ]; then
echo "Please specify language code to generate/update"
2019-10-18 23:25:27 +02:00
exit -1
2019-10-18 21:19:29 +02:00
fi
locale="$1"
podir="./po/$locale"
echo "Selected locale: $locale"
mkdir -p "$podir"
pots=`find . -name '*.pot'`
for pot in $pots; do
po=`echo "$podir/${pot%.pot}.po" | sed -e "s/\/.\//\//g"`
echo -n "$po: "
if [ -f "$po" ]; then
echo "update"
msgmerge --update "$po" "$pot"
else
echo "generate"
msginit --input="$pot" --locale="$locale" --output="$po"
fi
done