aboutsummaryrefslogtreecommitdiffstats
path: root/check_for_translation_work.sh
diff options
context:
space:
mode:
authorFilip Komar <filip@mageia.org>2013-05-05 11:44:36 +0000
committerFilip Komar <filip@mageia.org>2013-05-05 11:44:36 +0000
commit9b88427e897a7dd00b19bf05b2d5ccfa00cc9426 (patch)
tree44caa6347c6007107d6c1ee281d3589bd38a3778 /check_for_translation_work.sh
parentde4ca718e37c1540ba8544acfb089e1f8d791681 (diff)
downloadtools-9b88427e897a7dd00b19bf05b2d5ccfa00cc9426.tar
tools-9b88427e897a7dd00b19bf05b2d5ccfa00cc9426.tar.gz
tools-9b88427e897a7dd00b19bf05b2d5ccfa00cc9426.tar.bz2
tools-9b88427e897a7dd00b19bf05b2d5ccfa00cc9426.tar.xz
tools-9b88427e897a7dd00b19bf05b2d5ccfa00cc9426.zip
improved both methods for svn authentication, added README, many other updates and fixes
Diffstat (limited to 'check_for_translation_work.sh')
-rwxr-xr-xcheck_for_translation_work.sh258
1 files changed, 128 insertions, 130 deletions
diff --git a/check_for_translation_work.sh b/check_for_translation_work.sh
index d6d17ebf..7f2bfbc7 100755
--- a/check_for_translation_work.sh
+++ b/check_for_translation_work.sh
@@ -3,92 +3,67 @@
#
# Check for translation work by checking out / updating from SVN and
# displaying the project name when your language.po has fuzzy strings or
-# empty string messages.
+# empty string messages. Also useful for translation of web pages.
#
-# Filip Komar, 2012
+# Filip Komar, 2012, 2013
# Remco Rijnders, 2012
# $Id$
#
# Please see SVN for a list of changes to this script.
#
-#
-# Features:
-# -it's very configurable
-# -it logs all important actions
-# -it operates on list of "translation projects" in svn (including web pages)
-# -svn checkout or update as needed on every single project
-# -verbose checking for fuzzy and untranslated strings or just statistics (numbers of translated, fuzzy and untranslated strings) if required
-# -checking the syntax of po file from svn if required
-# -checking the syntax of pot file from svn if required
-# -copying the *.pot file, *.po file and web page files for editing in working directory if required
-# -testing for differences of *.po file from working copy if required
-# -testing for differences of *.pot file from working copy if required
-# -searching for new *.pot files in svn
-
-
-# TODO:
-# implement --password ARG to simplify svn authentication if used
-# simplify web copying part
-# more tests if target folder exist
-#
-# How to svn co single file (file.pot):
-# svn checkout $url_of_big_dir $target_dir --depth=empty
-# svn up $target_dir/$file_you_want
-# testing web pages checkout
-# better documentation
-#
+# More information about this script is in README file.
-if [ -f ~/.mageia-i18n-settings ]; then
- source ~/.mageia-i18n-settings
+
+if [ -f ~/.mageia-i18n-config ]; then
+ source ~/.mageia-i18n-config
else
- cat > ~/.mageia-i18n-settings << "EOF"
+ cat > ~/.mageia-i18n-config << "EOF"
# Please change the below values to match your needs:
language_code=xx
-user=svnusername_if_you_have_one
# Where to put the svn files and your working directory,
-# please make sure those folders exist.
-svn_folder="/home/user/Mageia/i18n/svn_anonymous"
-working_translations_folder="/home/user/Mageia/i18n/translations"
+# please make sure those directories exist before running the script!!!
+svn_directory="/home/user/Mageia/i18n/svn"
+working_translations_directory="/home/user/Mageia/i18n/translations"
-# choose svn method (user or anonymous)
-#svn_method="svn+ssh://$user@"
+# choose svn method:
+# 1. anonymous (no commit access)
svn_method="svn://"
+# 2. public ssh key svn access. Remember to upload it to identity!
+# Otherwise it will prompty you for password everytime for every resource.
+#svn_method="svn+ssh://"
+
# The following lines can be changed if you desire, but this is
# not needed to properly use this script.
-# choose quiet mode or normal
-#quiet_mode="-q"
-quiet_mode=""
-
# set checking syntax of po files with 1
check_po_syntax=1
-# set checking syntax of pot files with 1
-check_pot_syntax=0
-
-# set checking of fuzzy and untranslated strings with 1
-check_fuzzy_and_untranslated=0
-
# set copying of po files with 1
copying_po=1
# set copying of web page files with 1
copying_wp=1
+# ADVANCED SETTINGS
+# set checking syntax of pot files with 1
+check_pot_syntax=0
+
# set copying options (-i: interactive, -v: verbose, -u: update, -r: recursive)
copy_options="-ivur"
# choose log filename
log_filename="updated_translations_in_svn"
-log_folder="$svn_folder"
-logfile="$svn_folder/$log_filename"
-# switch of logging by uncommenting following line
+log_directory="$svn_directory"
+logfile="$svn_directory/$log_filename"
+
+# switch of logging by uncommenting the following line
#logfile="/dev/null"
-# set debug with 1
-debug=0
+# set checking of fuzzy and untranslated strings with 1
+# WARNING: listings can be really long
+check_fuzzy_and_untranslated=0
# set searching for new *.pot files in svn with 1
searching_for_new_pot_files_in_svn=0
@@ -97,17 +72,39 @@ searching_for_new_pot_files_in_svn=0
check_updates=1
EOF
- echo "This script has not been configured yet for your language. A template"
- echo "configuration file has been made in .mageia-i18n-settings in your"
- echo "home directory. Please edit this file according to your needs before"
- echo "running this script again"
+ echo "This script has not been configured yet for you. A template"
+ echo "configuration file named .mageia-i18n-config has been made in your"
+ echo "home directory. Please edit it according to your needs and remember"
+ echo "to create apropriate directories before running this script again."
echo
+ echo "For more information about this script please read README file."
exit
fi
+# save pwd to saved_dir
+saved_dir=$(pwd)
+
+if [ -f "$logfile"_this_run.log ]; then
+ mv "$logfile"_this_run.log "$logfile"_previous_run.log
+fi
+separator="-----------------------------------------------------"
+
+# Check if both directories exist
+if [ ! -d "$svn_directory" ]; then
+ mkdir -vp "$svn_directory/" | tee -a "$logfile"_this_run.log
+fi
+if [ ! -d "$working_translations_directory" ]; then
+ mkdir -vp "$working_translations_directory/" | tee -a "$logfile"_this_run.log
+fi
+
+echo "" | tee -a "$logfile"_this_run.log
+echo "" | tee -a "$logfile"_this_run.log
+date | tee -a "$logfile"_this_run.log
+
# Check if a newer version of this script is available. If yes, show the changes.
my_version=`echo "$Revision$" | cut -d" " -f2`
svn_version=`svn info svn://svn.mageia.org/svn/soft/i18n-tools/check_for_translation_work.sh | grep "Last Changed Rev:" | cut -c19-`
+echo Revision: $my_version | tee -a "$logfile"_this_run.log
if [ $check_updates -eq 1 ]; then
if [ $my_version -lt $svn_version ]; then
@@ -116,57 +113,43 @@ if [ $check_updates -eq 1 ]; then
let "tmp=$my_version + 1"
svn log -r $tmp:$svn_version svn://svn.mageia.org/svn/soft/i18n-tools/check_for_translation_work.sh
fi
- svn export svn://svn.mageia.org/svn/soft/i18n-tools/translation_projects.dat translation_projects.dat
+ svn export --force svn://svn.mageia.org/svn/soft/i18n-tools/translation_projects.dat "$svn_directory"
+ echo ""
fi
-# if you do have svn commit access, change the protocol from svn:// to svn+ssh://USERNAME@ in the projects array for easier committing...
declare -A projects
declare -A web_pages
-source translation_projects.dat
+source "$svn_directory/translation_projects.dat"
-# save pwd to saved_dir
-saved_dir=$(pwd)
-
-if [ -f "$logfile"_this_run.log ]; then
- mv "$logfile"_this_run.log "$logfile"_previous_run.log
-fi
-separator="-----------------------------------------------------"
-
-echo "" | tee -a "$logfile"_this_run.log
-echo "" | tee -a "$logfile"_this_run.log
-date | tee -a "$logfile"_this_run.log
echo "SW files:" | tee -a "$logfile"_this_run.log
# echo about checking the syntax of po file if required
- if [ $check_po_syntax -eq 1 ]; then
- echo "Syntax of $language_code.po in svn will be tested."
- fi
+if [ $check_po_syntax -eq 1 ]; then
+ echo "Syntax of $language_code.po in svn will be tested."
+fi
# echo about copying the *.pot file and $language_code.po for editing in apropriate directory if required
- if [ $copying_po -eq 1 ]; then
- echo "Files *.pot and $language_code.po will be copied into apropriate directory."
- fi
+if [ $copying_po -eq 1 ]; then
+ echo "Files *.pot and $language_code.po will be copied into apropriate directory."
+fi
-# Check out / update project files
for project_name in "${!projects[@]}"
do
echo $separator | tee -a "$logfile"_this_run.log
echo Working on: \'$project_name\' from \'${projects[$project_name]}\'. | tee -a "$logfile"_this_run.log
- if [ -d $project_name ]; then
- cd "$svn_folder/$project_name"
-# svn up $quiet_mode $project_name
+
+# Check out / update project files
+ if [ -d "$svn_directory/$project_name" ]; then
+ cd "$svn_directory/$project_name"
# just echo $language_code.po or *.pot file line if they are updated
svn up | grep -E "$language_code.po|[\.]pot" | tee -a "$logfile"_this_run.log
-# svn up $project_name | tee -a "$logfile"_this_run.log #2
# echo -n "" # debug
else
- cd "$svn_folder"
-# svn co -q ${projects[$project_name]} $project_name
-# svn co $quiet_mode $svn_method${projects[$project_name]} $project_name
+ cd "$svn_directory"
# just echo $language_code.po or *.pot file line if they are updated
svn co $svn_method${projects[$project_name]} $project_name | grep -E "$language_code.po|[\.]pot" | tee -a "$logfile"_this_run.log
# echo -n "" # debug
- cd "$svn_folder/$project_name"
+ cd "$svn_directory/$project_name"
fi
# verbose checking for fuzzy and untranslated strings
@@ -196,26 +179,26 @@ do
# copying the *.pot file and $language_code.po for editing in working directory if required
if [ $copying_po -eq 1 ]; then
- if [ ! -d "$working_translations_folder/$project_name/" ]; then
- mkdir -v "$working_translations_folder/$project_name/" | tee -a "$logfile"_this_run.log
+ if [ ! -d "$working_translations_directory/$project_name/" ]; then
+ mkdir -vp "$working_translations_directory/$project_name/" | tee -a "$logfile"_this_run.log
fi
if [ -f $language_code.po ]; then
# testing for differences of *.po file from working copy
- if [ -f "$working_translations_folder/$project_name/$language_code.po" ]; then
- diff -q $language_code.po "$working_translations_folder/$project_name/$language_code.po" | tee -a "$logfile"_this_run.log
+ if [ -f "$working_translations_directory/$project_name/$language_code.po" ]; then
+ diff -q $language_code.po "$working_translations_directory/$project_name/$language_code.po" | tee -a "$logfile"_this_run.log
fi
- cp $copy_options $language_code.po "$working_translations_folder/$project_name/" | tee -a "$logfile"_this_run.log
+ cp $copy_options $language_code.po "$working_translations_directory/$project_name/" | tee -a "$logfile"_this_run.log
else
echo "File $language_code.po is not present in $project_name. Copying is not possible." | tee -a "$logfile"_this_run.log
fi
if [ -f *.pot ]; then
# testing for differences of *.pot file from working copy
- if [ -f "$working_translations_folder/$project_name/"*.pot ]; then
- diff -q *.pot "$working_translations_folder/$project_name/"*.pot | tee -a "$logfile"_this_run.log
+ if [ -f "$working_translations_directory/$project_name/"*.pot ]; then
+ diff -q *.pot "$working_translations_directory/$project_name/"*.pot | tee -a "$logfile"_this_run.log
fi
- cp $copy_options *.pot "$working_translations_folder/$project_name/" | tee -a "$logfile"_this_run.log
+ cp $copy_options *.pot "$working_translations_directory/$project_name/" | tee -a "$logfile"_this_run.log
# set -x # turn tracing on with set -x
- cd "$working_translations_folder/$project_name/"
+ cd "$working_translations_directory/$project_name/"
if [ -f *.pot_$language_code.po ]; then
# creating new_pot_lang.po from latest *.pot file
msgmerge -q *.pot_$language_code.po *.pot > new_pot_$language_code.po # msgmerge *.pot_lang.po *.pot > new_pot_lang.po
@@ -254,9 +237,9 @@ do
else
echo "File *.pot is not present in $project_name. Copying is not possible." | tee -a "$logfile"_this_run.log
fi
-# echo "Files *.pot and $language_code.po copied into $working_translations_folder/$project_name/."
+# echo "Files *.pot and $language_code.po copied into $working_translations_directory/$project_name/."
fi
- cd "$svn_folder/"
+ cd "$svn_directory/"
echo "" | tee -a "$logfile"_this_run.log
done
@@ -268,61 +251,70 @@ do
echo Working on: "$web_page_name" from "${web_pages[$web_page_name]}". | tee -a "$logfile"_this_run.log # \'
# turn tracing on with set -x
# set -x
- if [ -d "$svn_folder/$web_page_name/" ]; then
- cd "$svn_folder/$web_page_name"
-# svn up $quiet_mode $web_page_name
+ if [ -d "$svn_directory/$web_page_name/" ]; then
+ cd "$svn_directory/$web_page_name"
# just echo $language_code.lang or *.php file line if they are updated
svn up | grep -E "$language_code.lang|en.lang|[\.]php" | tee -a "$logfile"_this_run.log
# echo -n "" # debug
else
- cd "$svn_folder/"
-# svn co -q ${web_pages[$web_page_name]} $web_page_name
-# svn co $quiet_mode $svn_method${web_pages[$web_page_name]} $web_page_name
+ cd "$svn_directory/"
# just echo $language_code.lang or *.php file line if they are updated
svn co $svn_method${web_pages[$web_page_name]} $web_page_name | grep -E "$language_code.lang|en.lang|[\.]php" | tee -a "$logfile"_this_run.log
echo -n "" | tee -a "$logfile"_this_run.log
- cd "$svn_folder/$web_page_name"
+ cd "$svn_directory/$web_page_name"
fi
echo "" | tee -a "$logfile"_this_run.log
done
-#copying the *.php file and $language_code.lang for editing in upper directory if required
+#copying the english files and $language_code.lang files for editing in working directory if required
if [ $copying_wp -eq 1 ]; then
echo $separator | tee -a "$logfile"_this_run.log
-# echo about copying the *.php file and $language_code.lang for editing in upper directory if required
echo "Web files will be copied (updated) into working translations directory."
- cd "$svn_folder"
- cp $copy_options ./web_page_english/index.php "$working_translations_folder/web_page_english/" | tee -a "$logfile"_this_run.log
- cp $copy_options ./web_page_english/2/download_index.php "$working_translations_folder/web_page_english/2/" | tee -a "$logfile"_this_run.log
- cp $copy_options ./web_page_english/2/index.php "$working_translations_folder/web_page_english/2/" | tee -a "$logfile"_this_run.log
- cp $copy_options ./web_page_english/2/nav.php "$working_translations_folder/web_page_english/2/" | tee -a "$logfile"_this_run.log
- cp $copy_options ./web_page_english/about/index.php "$working_translations_folder/web_page_english/about/" | tee -a "$logfile"_this_run.log
- cp $copy_options ./web_page_english/for-pc/index.php "$working_translations_folder/web_page_english/for-pc/" | tee -a "$logfile"_this_run.log
- cp $copy_options ./web_page_english/for-server/index.php "$working_translations_folder/web_page_english/for-server/" | tee -a "$logfile"_this_run.log
- cp $copy_options ./web_page_english/map/index.php "$working_translations_folder/web_page_english/map/" | tee -a "$logfile"_this_run.log
- cp $copy_options ./web_page_english/support/index.php "$working_translations_folder/web_page_english/support/" | tee -a "$logfile"_this_run.log
- cp $copy_options ./web_page_my_language/about/2010-sept-announcement.html "$working_translations_folder/web_page_my_language/about/" | tee -a "$logfile"_this_run.log
- cp $copy_options ./web_pages_lang/en/* "$working_translations_folder/web_pages_lang/en/" | tee -a "$logfile"_this_run.log
- cp $copy_options ./web_pages_lang/$language_code/* "$working_translations_folder/web_pages_lang/$language_code/" | tee -a "$logfile"_this_run.log
- cp $copy_options ./web_page_navigation/fr.lang "$working_translations_folder/web_page_navigation/" | tee -a "$logfile"_this_run.log
- cp $copy_options ./web_page_navigation/$language_code.lang "$working_translations_folder/web_page_navigation/" | tee -a "$logfile"_this_run.log
+ cd "$svn_directory"
+
+ if [ ! -d "$working_translations_directory/web_pages_lang/en/" ]; then
+ mkdir -vp "$working_translations_directory/web_pages_lang/en/" | tee -a "$logfile"_this_run.log
+ fi
+ cp $copy_options ./web_pages_lang/en/* "$working_translations_directory/web_pages_lang/en/" | tee -a "$logfile"_this_run.log
+ if [ ! -d "$working_translations_directory/web_pages_lang/$language_code/" ]; then
+ mkdir -vp "$working_translations_directory/web_pages_lang/$language_code/" | tee -a "$logfile"_this_run.log
+ fi
+ cp $copy_options ./web_pages_lang/$language_code/* "$working_translations_directory/web_pages_lang/$language_code/" | tee -a "$logfile"_this_run.log
+ if [ ! -d "$working_translations_directory/web_page_navigation/" ]; then
+ mkdir -vp "$working_translations_directory/web_page_navigation/" | tee -a "$logfile"_this_run.log
+ fi
+ cp $copy_options ./web_page_navigation/en.lang "$working_translations_directory/web_page_navigation/" | tee -a "$logfile"_this_run.log
+ cp $copy_options ./web_page_navigation/$language_code.lang "$working_translations_directory/web_page_navigation/" | tee -a "$logfile"_this_run.log
fi
# turn tracing off with set +x
# set +x
-diff -rq "$svn_folder/web_page_navigation" "$svn_folder/web_page_navigation_2" | grep -E ".lang" | tee -a "$logfile"_this_run.log
+if [ -d "$svn_directory/web_page_navigation/" ]; then
+ if [ -d "$svn_directory/web_page_navigation_2/" ]; then
+ diff -rq "$svn_directory/web_page_navigation" "$svn_directory/web_page_navigation_2" | grep -E ".lang" | tee -a "$logfile"_this_run.log
+ else
+ echo "Both navigation directories ($svn_directory/web_page_navigation and $svn_directory/web_page_navigation_2) are not present. Comparing is not possible." | tee -a "$logfile"_this_run.log
+ fi
+else
+ echo "Both navigation directories ($svn_directory/web_page_navigation and $svn_directory/web_page_navigation_2) are not present. Comparing is not possible." | tee -a "$logfile"_this_run.log
+fi
+echo "" | tee -a "$logfile"_this_run.log
if [ $searching_for_new_pot_files_in_svn -eq 1 ]; then
echo $separator | tee -a "$logfile"_this_run.log
echo "Searching for new *.pot files in svn." | tee -a "$logfile"_this_run.log
- mv "$log_folder"/new_svn_list_of_pot_files "$log_folder"/old_svn_list_of_pot_files # -f
- svn list -R svn://svn.mageia.org/svn/soft/ > "$log_folder"/svn_list
- cat "$log_folder"/svn_list | grep [\.]pot > "$log_folder"/new_svn_list_of_pot_files
+ if [ -f "$log_directory"/new_svn_list_of_pot_files ]; then
+ mv "$log_directory"/new_svn_list_of_pot_files "$log_directory"/old_svn_list_of_pot_files # -f
+ fi
+ svn list -R svn://svn.mageia.org/svn/soft/ > "$log_directory"/svn_list
+ cat "$log_directory"/svn_list | grep [\.]pot > "$log_directory"/new_svn_list_of_pot_files
# svn list -R svn://svn.mageia.org/svn/soft/ | grep [\.]pot > new_svn_list_of_pot_files
- diff new_svn_list_of_pot_files old_svn_list_of_pot_files | tee -a "$logfile"_this_run.log
- if [ ${PIPESTATUS[0]} -eq 0 ]; then # this reads exit status of first command in pipe
- echo "No new *.pot files found." | tee -a "$logfile"_this_run.log
+ if [ -f "$log_directory"/old_svn_list_of_pot_files ]; then
+ diff new_svn_list_of_pot_files old_svn_list_of_pot_files | tee -a "$logfile"_this_run.log
+ if [ ${PIPESTATUS[0]} -eq 0 ]; then # this reads exit status of first command in pipe
+ echo "No new *.pot files found." | tee -a "$logfile"_this_run.log
+ fi
fi
echo "" | tee -a "$logfile"_this_run.log
fi
@@ -332,9 +324,15 @@ fi
cat "$logfile"_this_run.log >> "$logfile"_full.log
echo "" | tee -a "$logfile".log
echo $separator | tee -a "$logfile".log
-echo "Differences from last run:" | tee -a "$logfile".log
-# show only differences and log them
-diff "$logfile"_this_run.log "$logfile"_previous_run.log | tee -a "$logfile".log
+
+if [ -f "$logfile"_previous_run.log ]; then
+ # show only differences and log them
+ echo "Differences from last run:" | tee -a "$logfile".log
+ diff "$logfile"_this_run.log "$logfile"_previous_run.log | tee -a "$logfile".log
+fi
+
+# if you use this script by click it in GUI uncomment the next line
+#read -p "Press any key to continue... " -n1 -s
# restore saved_dir
cd "$saved_dir"