#!/bin/sh
# Extract messages for translation from Python source and .ui, .rc and .kcfg files.
#
#
BASEDIR="src"    # root of translatable sources
PROJECT="guidedog"      # project name
BUGADDR="http://www.simonzone.com/software/guidedog/"      # MSGID-Bugs

#-------------------------------------------------------------------------
WDIR=`pwd`              # working dir
 
#echo "Preparing rc files"
cd ${BASEDIR}
# we use simple sorting to make sure the lines do not jump around too much from system to system
find . -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort > ${WDIR}/rcfiles.list
xargs --arg-file=${WDIR}/rcfiles.list $EXTRACTRC --language=Python > ${WDIR}/rc.py
# additional string for KAboutData
echo 'i18nc("NAME OF TRANSLATORS","Your names");' >> ${WDIR}/rc.py
echo 'i18nc("EMAIL OF TRANSLATORS","Your emails");' >> ${WDIR}/rc.py
cd ${WDIR}
#echo "Done preparing rc files"
  
   
#echo "Extracting messages"
cd ${BASEDIR}
# see above on sorting
find . -name '*.py' | sort > ${WDIR}/infiles.list
echo "rc.py" >> ${WDIR}/infiles.list
cd ${WDIR}
xgettext --from-code=UTF-8 -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 -ktr2i18n:1 \
  -kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kaliasLocale -kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3 \
  --msgid-bugs-address="${BUGADDR}" \
  --files-from=infiles.list -D ${BASEDIR} -D ${WDIR} -o ${podir}/${PROJECT}.pot || { echo "error while calling xgettext. aborting."; exit 1; }
#echo "Done extracting messages"
                    
                     
#echo "Cleaning up"
cd ${WDIR}
rm rcfiles.list
rm infiles.list
rm rc.py
#echo "Done"
