File indexing completed on 2024-04-21 04:53:47

0001 #!/bin/bash
0002 # Simplified variant of https://github.com/KDE/marble/tree/master/data/lang/download-pos.sh
0003 #
0004 # The translations are managed by KDE Localization.
0005 # This script can be used to download them into this folder in order to build
0006 # Kid3 with bundled translations.
0007 # Translation status: https://l10n.kde.org/stats/gui/trunk-kf5/po/kid3_qt.po/
0008 # To extract the translatable messages, proceed as described in
0009 # https://techbase.kde.org/Development/Tutorials/Localization/i18n_Build_Systems
0010 # Use --force-en as a parameter to force extraction of English plurals.
0011 
0012 set -e
0013 
0014 force_en=false
0015 if test "$1" = "--force-en"; then
0016   force_en=true
0017   shift
0018 fi
0019 
0020 podir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/po
0021 branch=${1:-trunk}
0022 svn_path_prefix="svn://anonsvn.kde.org/home/kde/$branch/l10n-kf5"
0023 svn_folder="messages/kid3"
0024 mkdir -p "$podir"
0025 svn -q export "$svn_path_prefix/templates/$svn_folder/kid3_qt.pot" "$podir/kid3_qt.pot"
0026 echo "Downloaded po/kid3_qt.pot"
0027 workdir="$(mktemp -d)"
0028 pofile="$workdir/kid3_qt.po"
0029 subdirs="$workdir/subdirs"
0030 svn -q export "$svn_path_prefix/subdirs" $subdirs
0031 for lang in $(cat $subdirs); do
0032   test "$lang" = "x-test" && continue
0033   svn -q export "$svn_path_prefix/$lang/$svn_folder/kid3_qt.po" $pofile >/dev/null 2>&1 || true
0034   if test -e $pofile; then
0035     target_dir="$podir/$lang"
0036     mkdir -p $target_dir
0037     mv -f $pofile $target_dir
0038     echo "Downloaded po/$lang"
0039   fi
0040 done
0041 
0042 if ! test -f po/en/kid3_qt.po || $force_en; then
0043   echo "Extracting po/en/kid3_qt.po"
0044   if hash extract-messages.sh 2>/dev/null; then
0045     cd ..
0046     mkdir -p po enpo
0047     extract-messages.sh
0048     cd -
0049     if test -f ../enpo/kid3_qt.po; then
0050       mkdir -p po/en
0051       mv ../enpo/kid3_qt.po po/en/
0052     else
0053       echo "ERROR: ../enpo/kid3_qt.po with English plurals not found."
0054       exit 1
0055     fi
0056     rmdir ../enpo
0057     rm -f ../po/kid3_qt.pot
0058   else
0059     echo "ERROR: po/en/kid3_qt.po is missing and extract-messages.sh not found in PATH."
0060     echo "Get svn://anonsvn.kde.org/home/kde/trunk/l10n-kf5/scripts and add it to the PATH!"
0061     exit 1
0062   fi
0063 else
0064   echo "Using existing po/en/kid3_qt.po"
0065 fi