wesnoth-l10n-tools/pack

83 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
# Pack translations
# Copyright (C) 2007-2008 Andrius Štikonas <stikonas@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
source "`dirname $0`/variables"
if [ ! $DIFF ]; then
echo -e $RED"This program needs the diff utility."$ENDCOLOR
exit 1
fi
if [ ! $TAR ]; then
echo -e $RED"This program needs the tar utility."$ENDCOLOR
exit 1
fi
if [ ! $BZIP2 ]; then
echo -e $RED"This program needs the bzip2 utility."$ENDCOLOR
exit 1
fi
counter=0
for BRANCH in $TRUNK $BRANCHES; do
echo -e "Branch: $BLUE$BRANCH"$ENDCOLOR
DIR="$PREFIX-$BRANCH"
mkdir "$LCODE-temp"
for file in `find $DIR -name *.lt.po`; do
bfile=`basename $file`
echo -n "Processing catalog $bfile... ";
d=`echo "$bfile" | sed "s/.$LCODE.po//"`
dirdomain=`echo wesnoth-$d | sed "s/wesnoth-wesnoth/wesnoth/"`
$MSGMERGE --silent "$file" "$file" -o $file.temp
mv $file.temp $file
if [ -f "$BRANCH/$dirdomain/$LCODE.po" ]; then
$MSGMERGE --silent "$BRANCH/$dirdomain/$LCODE.po" "$BRANCH/$dirdomain/$LCODE.po" -o "$BRANCH/$dirdomain/$LCODE.po.temp"
if ! $DIFF -q "$file" "$BRANCH/$dirdomain/$LCODE.po.temp" > /dev/null ; then
mkdir "$LCODE-temp/$dirdomain"
cp "$file" "$LCODE-temp/$dirdomain/$LCODE.po"
echo -e $GREEN"OK"$ENDCOLOR
counter=$(($counter+1))
else
echo -e $BLUE"Skipping"$ENDCOLOR
fi
rm "$BRANCH/$dirdomain/$LCODE.po.temp"
else
mkdir -p "$LCODE-temp/$dirdomain"
cp "$file" "$LCODE-temp/$dirdomain/$LCODE.po"
echo -e $GREEN"OK"$ENDCOLOR
counter=$(($counter+1))
fi
done
if [ -f "$LCODE-$BRANCH.tar.bz2" ]; then
echo "Removing old archive."
rm -f "$LCODE-$BRANCH.tar.bz2"
fi
if [ ! $counter -eq 0 ]; then
cd $LCODE-temp
$TAR --remove-files -cf ../$LCODE-$BRANCH.tar wesnoth*
cd ..
$BZIP2 --best $LCODE-$BRANCH.tar
echo "New archive created."
fi
rmdir $LCODE-temp
done
echo -e $GREEN"Finished."$ENDCOLOR