85 lines
2.6 KiB
Bash
85 lines
2.6 KiB
Bash
#! /bin/bash
|
|
|
|
set -o errexit
|
|
|
|
if test "$1" = "--help" ; then
|
|
echo "Upstream translation update tool works in top directory of unpacked source code."
|
|
echo "Usage: $0 [translation_directory]"
|
|
fi
|
|
|
|
# Update all known mechanisms to add language:
|
|
function linguas_update {
|
|
if test -f LINGUAS ; then
|
|
echo "Adding $LNG to LINGUAS."
|
|
echo $LNG >>LINGUAS
|
|
fi
|
|
if test -f $OLDPWD/configure.ac ; then
|
|
if grep -q 'ALL_LINGUAS=' $OLDPWD/configure.ac ; then
|
|
echo "Adding $LNG to configure.ac."
|
|
sed -i 's/ALL_LINGUAS="/&'$LNG' /;s/\(ALL_LINGUAS=\)\([^"]\|$\)/\1"'$LNG' "\2/' $OLDPWD/configure.ac
|
|
fi
|
|
fi
|
|
if test -f $OLDPWD/configure.in ; then
|
|
if grep -q 'ALL_LINGUAS=' $OLDPWD/configure.in ; then
|
|
echo "Adding $LNG to configure.in."
|
|
sed -i 's/ALL_LINGUAS="/&'$LNG' /;s/\(ALL_LINGUAS=\)\([^"]\|$\)/\1"'$LNG' "\2/' $OLDPWD/configure.in
|
|
fi
|
|
fi
|
|
if test -f $OLDPWD/configure ; then
|
|
if grep -q 'ALL_LINGUAS=' $OLDPWD/configure ; then
|
|
echo "Adding $LNG to configure."
|
|
sed -i 's/ALL_LINGUAS="/&'$LNG' /;s/\(ALL_LINGUAS=\)\([^"]\|$\)/\1"'$LNG' "\2/' $OLDPWD/configure
|
|
fi
|
|
fi
|
|
}
|
|
|
|
DIR=${1:-po}
|
|
|
|
cd $DIR
|
|
|
|
intltool-update --pot
|
|
|
|
POT_NOT_UNIQUE=false
|
|
for POT in *.pot ; do
|
|
if $POT_NOT_UNIQUE ; then
|
|
echo "ERROR: Directory $DIR contains more than one .pot file."
|
|
exit 1
|
|
fi
|
|
POT_NOT_UNIQUE=true
|
|
DOMAIN=${POT%.pot}
|
|
|
|
# STRING_COLLECT_MODE is a special mode used during string
|
|
# collection. STRING_COLLECT_DIR must be set as well.
|
|
if test "$STRING_COLLECT_MODE" = 1 ; then
|
|
mkdir $STRING_COLLECT_DIR/$DOMAIN
|
|
cp -a $POT $STRING_COLLECT_DIR/$DOMAIN
|
|
cp -a *.po $STRING_COLLECT_DIR/$DOMAIN
|
|
else
|
|
if test -d /usr/share/translation-update-upstream ; then
|
|
if test -d /usr/share/translation-update-upstream/$DOMAIN ; then
|
|
for PO_PATH in /usr/share/translation-update-upstream/$DOMAIN/*.po ; do
|
|
PO=${PO_PATH##*/}
|
|
LNG=${PO%.po}
|
|
if test -f $PO ; then
|
|
echo "Updating $PO using translation-update-upstream."
|
|
# PO_PATH is first: Update any string, even if it was already translated.
|
|
# Swap $PO_PATH and $PO to disable this behavior.
|
|
msgcat --use-first $PO_PATH $PO -o $PO.new
|
|
msgmerge --no-fuzzy-matching --compendium=$PO_PATH -o $PO $PO.new $POT
|
|
rm $PO.new
|
|
else
|
|
echo "Adding $PO from translation-update-upstream."
|
|
cp -a $PO_PATH $PO
|
|
linguas_update
|
|
fi
|
|
done
|
|
else
|
|
echo "WARNING: Package translation-update-upstream does not contain any update for $DOMAIN."
|
|
fi
|
|
else
|
|
echo "ERROR: Package translation-update-upstream is not installed. Please update your BuildRequires!"
|
|
exit 1
|
|
fi
|
|
fi
|
|
done
|