webroot/PO/mkpotfiles.sh

62 lines
1.3 KiB
Bash

#!/bin/sh
SELF="$(realpath "$0")"
PODIR="$(dirname "$SELF")"
PROJECT_ROOT="$(dirname "$PODIR")"
cd "$PODIR"
echo "Creating POTFILES"
rm -v POTFILES
for i in $(find ../src | grep '\.php' | grep -v '\.\./src/MyDevel'); do
echo $i >> POTFILES
done
if [ -f messages.pot ]; then
JOIN="--join-existing"
else
JOIN=""
fi
echo "extracting messages"
xgettext -f POTFILES -d messages -L PHP $JOIN --force-po -o messages.pot
if [ -z "$JOIN" ]; then
sed -i s/charset=CHARSET/charset=UTF-8/g messages.pot
fi
for i in `cat LINGUAS`; do
if [ ! -f $i.po ]; then
cp messages.pot $i.po
else
msgmerge $i.po messages.pot
fi
done
echo "Creating POTFILES.webroot"
rm -v POTFILES.webroot
for i in $(find ../src/MyDevel/Webroot | grep '\.php'); do
echo $i >> POTFILES.webroot
done
if [ ! -d webroot ]; then
mkdir -v webroot
fi
if [ -f webroot/messages.pot ]; then
JOIN="--join-existing"
else
JOIN=""
fi
xgettext -d mydevel.webroot -f POTFILES.webroot -L PHP $JOIN --force-po -o webroot/messages.pot
if [ -z "$JOIN" ]; then
sed -i s/charset=CHARSET/charset=UTF-8/g webroot/messages.pot
fi
for i in `cat LINGUAS`; do
if [ ! -f webroot/$i.po ]; then
cp webroot/messages.pot webroot/$i.po
else
msgmerge webroot/$i.po webroot/messages.pot
fi
done