File indexing completed on 2024-12-08 06:34:01

0001 #!/bin/bash
0002 
0003 # A script to download Marble Qt translations from KDE's SVN.
0004 #
0005 # To be used before cmake is called on the sources.
0006 #
0007 # SPDX-License-Identifier: LGPL-2.1-or-later
0008 #
0009 # SPDX-FileCopyrightText: 2016 Friedrich W. H. Kossebau <kossebau@kde.org>
0010 #
0011 
0012 # TODO: support updates properly (e.g. removing no longer existing po files)
0013 
0014 has_subdirs=true
0015 case "$1" in
0016     trunk)
0017         echo "Downloading from trunk"
0018         svn_path_prefix="svn://anonsvn.kde.org/home/kde/trunk/l10n-kf5"
0019         ;;
0020     stable)
0021         echo "Downloading from stable"
0022         svn_path_prefix="svn://anonsvn.kde.org/home/kde/branches/stable/l10n-kf5"
0023         ;;
0024     "")
0025         echo "Syntax: $0 trunk|stable|\"KDE Applications tag\" [lang]"
0026         exit 1
0027         ;;
0028     *)
0029         TAG=$1
0030         echo "Downloading from KDE Applications tag $1"
0031         svn_path_prefix="svn://anonsvn.kde.org/home/kde/tags/Applications/${TAG}/kde-l10n/5"
0032         has_subdirs=false
0033         ;;
0034 esac
0035 
0036 if [ ! -e data/lang ]; then
0037     echo "$0 needs to be invoked from the toplevel source dir."
0038     exit 1
0039 fi
0040 
0041 shift
0042 
0043 workdir="$(mktemp -d)"
0044 pofile="${workdir}//marble_qt.po"
0045 
0046 if [ $# -gt 0 ] ; then
0047     languages="${*}"
0048 else
0049     subdirs="${workdir}/subdirs"
0050     if [ "$has_subdirs" = true ] ; then
0051         svn -q export "${svn_path_prefix}/subdirs" ${subdirs}
0052     else
0053         # check if tag exists
0054         if svn info ${svn_path_prefix} > /dev/null 2>&1 ; then
0055             # tags don't have a subdirs file, so create one from the dirs present
0056             svn list ${svn_path_prefix} | egrep "/$"  | sed "s,/$,," > ${subdirs}
0057         else
0058             echo "There seems to be no tag $TAG."
0059             exit 1
0060         fi
0061     fi
0062     languages=$(cat ${subdirs})
0063 fi
0064 
0065 for i in ${languages}
0066 do
0067     svn -q export "${svn_path_prefix}/${i}/messages/kdeedu/marble_qt.po" ${pofile} > /dev/null 2>&1
0068     # some languages might not have a catalog
0069     if [ -e ${pofile} ]; then
0070         chmod a-w  ${pofile} # mark as not-to-be-edited
0071         target_dir="data/lang/po/${i}"
0072         mkdir -p ${target_dir}
0073         mv -f ${pofile} ${target_dir}
0074         echo "Downloaded for language $i"
0075     fi
0076 done
0077 
0078 if [ -e data/lang/po ]; then
0079     # TODO: think about some way to check if there are local modifications to prevent their loss
0080     touch data/lang/po/WARNING_CHANGES_TO_PO_FILES_WILL_BE_LOST
0081     # language files are only picked up at configuration time by a glob expression
0082     # TODO: think about some way to trigger this automatically, by detecting the need and changing some file
0083     echo "For picking up new languages, the CMake config needs to be redone, e.g. by calling: make rebuild_cache"
0084 fi