diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ dist/ _build/ +kde-l10n-svn/ .directory *.backup *.mo diff --git a/l10n_sync.sh b/l10n_sync.sh new file mode 100755 --- /dev/null +++ b/l10n_sync.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +# Synchronize translations with KDE SVN +# +# 1. Generate pot files +# 2. Copy pot files to KDE SVN +# 3. Copy po files from KDE SVN +# 4. Commit Krita Docs Git and KDE SVN +# +# Author: Guo Yunhe +# Date: 2018-07-24 + +# Project root +ROOT_DIR=$(realpath .) + +# SVN checkout path +SVN_DIR=$ROOT_DIR/kde-l10n-svn + +# SVN checkout & update +svn co "svn+ssh://svn@svn.kde.org/home/kde/trunk/l10n-kf5" $SVN_DIR +svn up $SVN_DIR + +# Template path +SVN_POT_DIR=$SVN_DIR/templates/docmessages/extragear-graphics + +# Remove old templates +rm $SVN_POT_DIR/krita--* + +# Git pull +git reset +git pull + +# Generate templates +make gettext +cd _build/gettext + +# Copy templates to SVN +for file in $(find . -name "*.pot") +do + file1="${file/\.\//}" + file2="${file1//\//--}" + file3="$SVN_POT_DIR/krita--$file2" + cp $file $file3 + svn add $file3 -q --parents --force >/dev/null +done + +# SVN commit +cd $SVN_DIR +svn commit -m "Update Krita document translation templates" + +# Copy translations to Git +for SVN_LOCALE_DIR in $(find $SVN_DIR -maxdepth 1 -type d ! -name .svn ! -name templates ! -name fr); do + if [ -d "$SVN_LOCALE_DIR/docmessages/extragear-graphics" ]; then + LOCALE=$(basename $SVN_LOCALE_DIR) + LOCALE_DIR=$ROOT_DIR/locale/$LOCALE/LC_MESSAGES + rm -r $LOCALE_DIR >/dev/null + mkdir -p $LOCALE_DIR + + cd $SVN_LOCALE_DIR/docmessages/extragear-graphics + + for file in $(find . -name "krita--*.po"); do + file1="${file/\.\/krita--/}" + file2="${file1//--/\/}" + file3="$LOCALE_DIR/$file2" + dir=$(dirname $file3) + mkdir -p $dir + cp $file $file3 + git add $file3 >/dev/null + done + fi +done + +# Git commit +cd $ROOT_DIR +git commit -m "Download translations from KDE SVN" +git push