File indexing completed on 2024-04-14 04:48:42

0001 #!/bin/bash
0002 # You usually should not call this script, it documents the process.
0003 # Use download-pos.sh instead, it will fetch the translations
0004 # from l10n.kde.org.
0005 
0006 BASEDIR="../src" # root of translatable sources
0007 PROJECT="kid3" # project name
0008 PROJECTVERSION="3.9.5" # project version
0009 BUGADDR="https://bugs.kde.org" # MSGID-Bugs
0010 WDIR=`pwd` # working dir
0011 
0012 # Use extract-merge.sh if found in the path, its from
0013 # svn://anonsvn.kde.org/home/kde/trunk/l10n-kf5/scripts
0014 if test -f po/${PROJECT}_qt.pot; then
0015   echo "NOTE: Keeping po/${PROJECT}_qt.pot, delete it to extract messages"
0016 elif hash extract-messages.sh 2>/dev/null; then
0017   echo "Using extract-messages.sh from l10n-kf5/scripts"
0018   cd ..
0019   mkdir -p po enpo
0020   extract-messages.sh
0021   cd -
0022   mkdir -p po
0023   mv ../po/* po
0024   if test -f ../enpo/kid3_qt.po; then
0025     mkdir -p po/en
0026     mv ../enpo/kid3_qt.po po/en/
0027   fi
0028   rmdir ../po ../enpo
0029 else
0030   echo "extract-messages.sh not found in path, falling back to custom extraction"
0031 
0032   echo "Preparing rc files"
0033   cd ${BASEDIR}
0034   # we use simple sorting to make sure the lines do not jump around too much from system to system
0035   find . -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort > ${WDIR}/rcfiles.list
0036   xargs --arg-file=${WDIR}/rcfiles.list extractrc > ${WDIR}/rc.cpp
0037   cd ${WDIR}
0038   echo "Done preparing rc files"
0039 
0040   echo "Extracting messages"
0041   cd ${BASEDIR}
0042   # see above on sorting
0043   find . -name '*.cpp' -o -name '*.h' -o -name '*.c' -o -name '*.hpp' -o -name '*.qml' | sort > ${WDIR}/infiles.list
0044   echo "rc.cpp" >> ${WDIR}/infiles.list
0045   cd ${WDIR}
0046   mkdir -p po
0047   xgettext --from-code=UTF-8 -C --qt -ci18n -ktr:1,1t -ktr:1,2c,2t -ktr:1,1,2c,3t \
0048     -kQT_TRANSLATE_NOOP:1,1t -kQT_TRANSLATE_NOOP:2,2t \
0049     -kqsTr:1,1t -kqsTr:1,2c,2t -kqsTr:1,1,2c,3t \
0050     -kqsTrNoOp:1,1t -kqsTrNoOp:2,2t \
0051     --msgid-bugs-address="${BUGADDR}" \
0052     --package-name="${PROJECT^}" \
0053     --package-version="${PROJECTVERSION}" \
0054     --files-from=infiles.list -D ${BASEDIR} -D ${WDIR} -o po/${PROJECT}_qt.pot || { echo "error while calling xgettext. aborting."; exit 1; }
0055   echo "Done extracting messages"
0056   rm rcfiles.list
0057   rm infiles.list
0058   rm rc.cpp
0059 fi
0060 
0061 echo "Merging translations"
0062 CATALOGS=`find po -name '*.po'`
0063 for CAT in $CATALOGS; do
0064   if test "$CAT" != "po/en/kid3_qt.po"; then
0065     echo $CAT
0066     msgmerge --quiet --update --backup=none $CAT po/${PROJECT}_qt.pot
0067   fi
0068 done
0069 echo "Done"