gnome-patch-translation/gnome-patch-translation-update

61 lines
2.2 KiB
Bash

#! /bin/bash
set -o errexit
# This action takes some time. But run it every time to confirm, that update is still needed.
cd po
intltool-update --pot
mkdir ../gnome-patch-translation/new
cp -a *.pot ../gnome-patch-translation/new
cd ../gnome-patch-translation/new
eval POT=$(echo *)
POT=${POT%.pot}
cd ..
msgcomm --unique -o $POT-unique.pot old/$POT.pot new/$POT.pot
if test $? -eq 0 -a ! -f $POT-unique.pot ; then
echo ""
echo "No unique patch specific strings in project!"
echo "You can remove gnome-patch-translation support from this project."
echo ""
exit 1
fi
msgcomm --more-than=1 -o $POT-patch.pot $POT-unique.pot new/$POT.pot
rm -rf new old $POT-unique.pot
cd ../po
# Main action. Only this is really needed for package rebuild.
for PO in *.po ; do
LNG=${PO%.po}
if test -f /usr/share/gnome-patch-translation/$LNG.po ; then
echo "Updating $PO using gnome-patch-translation compendium."
if test "$COMPENDIUM_UPDATE_MODE" = 1 ; then
msgmerge --compendium=/usr/share/gnome-patch-translation/$LNG.po -o $PO.new $PO $POT.pot
else
# For compilation use --no-fuzzy-matching to run faster.
msgmerge --no-fuzzy-matching --compendium=/usr/share/gnome-patch-translation/$LNG.po -o $PO.new $PO $POT.pot
fi
mv $PO.new $PO
fi
done
# This action takes long time. Run it only if we really need it.
if test "$COMPENDIUM_UPDATE_MODE" = 1 ; then
sed -i 's@#: \.\./@#: '$POT'/@' ../gnome-patch-translation/$POT-patch.pot
for PO in *.po ; do
LNG=${PO%.po}
echo "Creating fuzzy $PO for gnome-patch-translation."
msgmerge -o ../gnome-patch-translation/$POT-$LNG.po $PO ../gnome-patch-translation/$POT-patch.pot
sed -i 's@#: \.\./@#: '$POT'/@;/#~/,$d' ../gnome-patch-translation/$POT-$LNG.po
done
echo "================================================================="
echo " Translatable strings from patches were written to"
echo " gnome-patch-translation/. If you did any translatable string"
echo " change in any patch, please follow HOWTO in"
echo " gnome-patch-translation package source."
echo "================================================================="
else
echo " Skipping compendium update. Use COMPENDIUM_UPDATE_MODE=1 to force it."
fi