aboutsummaryrefslogtreecommitdiffstats
path: root/check_for_translation_work.sh
diff options
context:
space:
mode:
authorfilip <filip.komar@gmail.com>2013-10-31 22:58:05 +0100
committerfilip <filip.komar@gmail.com>2013-10-31 22:59:09 +0100
commit004b991f5e03c437d5b5ab78d775604a3210c22d (patch)
tree667dcb50be0ce6e7b010d86294ccfcca28655f95 /check_for_translation_work.sh
parent3051d584e8b6b2b48b1f9bf7ba4fac8bef2c1ee6 (diff)
downloadtools-004b991f5e03c437d5b5ab78d775604a3210c22d.tar
tools-004b991f5e03c437d5b5ab78d775604a3210c22d.tar.gz
tools-004b991f5e03c437d5b5ab78d775604a3210c22d.tar.bz2
tools-004b991f5e03c437d5b5ab78d775604a3210c22d.tar.xz
tools-004b991f5e03c437d5b5ab78d775604a3210c22d.zip
change of check_for_translation_work.sh script and it's db for git transition NOTE: add git_directory in your existing config file
Diffstat (limited to 'check_for_translation_work.sh')
-rwxr-xr-xcheck_for_translation_work.sh514
1 files changed, 379 insertions, 135 deletions
diff --git a/check_for_translation_work.sh b/check_for_translation_work.sh
index b5504925..1bac2f78 100755
--- a/check_for_translation_work.sh
+++ b/check_for_translation_work.sh
@@ -1,19 +1,18 @@
#!/bin/bash
# turn tracing on with /bin/bash -x
#
-# Check for translation work by checking out / updating from SVN and
+# Check for translation work by checking out / updating from GIT, SVN and
# displaying the project name when your language.po has fuzzy strings or
# empty string messages. Also useful for translation of web pages.
#
# Filip Komar, 2012, 2013
# Remco Rijnders, 2012
-# $Id$
+# $Id: check_for_translation_work.sh 8703 2013-10-31 22:47:00 filip $
#
-# Please see SVN for a list of changes to this script.
+# Please see git for a list of changes to this script.
#
# More information about this script is in README file.
-
if [ -f ~/.mageia-i18n-config ]; then
source ~/.mageia-i18n-config
else
@@ -21,9 +20,10 @@ else
# Please change the below values to match your needs:
language_code=xx
-# Where to put the svn files and your working directory,
+# Where to put the files from repositories and your working directory,
# please make sure those directories exist before running the script!!!
svn_directory="/home/user/Mageia/i18n/svn"
+git_directory="/home/user/Mageia/i18n/git" # added after git transition
working_translations_directory="/home/user/Mageia/i18n/translations"
# choose svn method:
@@ -31,7 +31,7 @@ working_translations_directory="/home/user/Mageia/i18n/translations"
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.
+# Otherwise it will prompt you for password everytime for every resource.
#svn_method="svn+ssh://"
# The following lines can be changed if you desire, but this is
@@ -43,14 +43,26 @@ check_po_syntax=1
# set copying of po files with 1
copying_po=1
+# uncomment next line to exclude copying of desktop files
+#copying_desktop_files=no
+
+# uncomment next line to exclude work on software desktop files resources
+#work_on_docs_and_tools=no
+
+# uncomment next line to exclude work on software desktop files resources
+#work_on_desktop_files=no
+
+# uncomment next line to exclude work on unofficial software resources
+#work_on_unofficial=no
+
+# uncomment next line to exclude work on html software resources
+#work_on_html_software_files=no
+
# set copying of web page files with 1
copying_wp=1
-# uncomment next line to exclude checkout of software resources for mageia 2
-#checkout_soft_mga2=no
-
-# uncomment next line to exclude checkout of software resources for mageia 3
-#checkout_soft_mga3=no
+# uncomment next line to exclude work on software resources for mageia 3
+#work_on_mga3=no
# ADVANCED SETTINGS
# set checking syntax of pot files with 1
@@ -60,37 +72,50 @@ check_pot_syntax=0
copy_options="-ivur"
# choose log filename
-log_filename="updated_translations_in_svn"
-log_directory="$svn_directory"
-logfile="$svn_directory/$log_filename"
+log_filename="updated_translations_in_git"
+log_directory="$git_directory"
+logfile="$git_directory/$log_filename"
# switch of logging by uncommenting the following line
#logfile="/dev/null"
-# set checking of fuzzy and untranslated strings with 1
-# WARNING: listings can be really long
-check_fuzzy_and_untranslated=0
-
# checkout whole website www.mageia.org and mognase navigation
checkout_whole_website=0
# set searching for new *.pot files in svn with 1
searching_for_new_pot_files_in_svn=0
-# whether to look for new versions of the script and project files
+# whether to look for new versions of the script and list of translatable resources
check_updates=1
# red color for differences from last time (green 32, blue 34)
color_for_differences=31
+# uncomment next line to show log with differences from last run
+#stop_showing_differences_from_last_run=yes
+
+# uncomment next line to prevent creation of working copy of po file
+#create_a_working_copy_of_po_file=no
+
EOF
+
+ echo -e "\E[31m"
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
+ echo -e "\E[m"
+ exit 1
+fi
+if [ -z "$git_directory" ]; then
+ echo -e "\E[31m"
+ echo "Please first set git_directory variable in your configuration file"
+ echo "named .mageia-i18n-config in your home directory before running"
+ echo "this script again."
+ echo -e "\E[m"
+ exit 2
fi
# save pwd to saved_dir
@@ -101,187 +126,389 @@ if [ -f "$logfile"_this_run.log ]; then
fi
separator="-----------------------------------------------------"
-# Check if both directories exist
+# Check if directories exist and create them if not
if [ ! -d "$svn_directory" ]; then
- mkdir -vp "$svn_directory/" | tee -a "$logfile"_this_run.log
+ mkdir -vp "$svn_directory/" # | tee -a "$logfile"_this_run.log
+fi
+if [ ! -d "$git_directory" ]; then
+ mkdir -vp "$git_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
- echo "You are running revision $my_version of this script, while $svn_version is available on SVN."
- echo "You may consider updating. Changes are:"
- let "tmp=$my_version + 1"
- svn log -r $tmp:$svn_version svn://svn.mageia.org/svn/soft/i18n-tools/check_for_translation_work.sh
+ if [ -f "$git_directory"/translation_projects.dat ]; then
+ mv "$git_directory"/translation_projects.dat "$git_directory"/translation_projects.dat_previous
+ fi
+ wget -Nq http://gitweb.mageia.org/software/i18n/tools/plain/translation_projects.dat "$git_directory"
+ if [ -f "$git_directory"/check_for_translation_work.sh ]; then
+ mv "$git_directory"/check_for_translation_work.sh "$git_directory"/check_for_translation_work.sh_previous
+ fi
+ wget -Nq http://gitweb.mageia.org/software/i18n/tools/plain/check_for_translation_work.sh "$git_directory"
+ if [ -f "$git_directory"/check_for_translation_work.sh_previous ]; then
+ diff -q "$git_directory"/check_for_translation_work.sh "$git_directory"/check_for_translation_work.sh_previous > /dev/null
+ if [ $? -eq 1 ]; then # there are differences
+ echo -e "\E[33m"
+ echo $separator | tee -a "$logfile"_this_run.log
+ echo You are running an old revision of this script. You may consider updating. Changes are: | tee -a "$logfile"_this_run.log
+ diff "$git_directory"/check_for_translation_work.sh "$git_directory"/check_for_translation_work.sh_previous | tee -a "$logfile".log
+ echo -e "\E[m"
+ echo "" | tee -a "$logfile"_this_run.log
+ fi
fi
- svn export --force svn://svn.mageia.org/svn/soft/i18n-tools/translation_projects.dat "$svn_directory"
echo ""
fi
-declare -A projects
+declare -A git_addresses
+declare -A translate_projects_po
+declare -A translate_projects_desktop
+declare -A translate_projects_help
declare -A web_pages
-source "$svn_directory/translation_projects.dat"
+if [ -f "$git_directory"/translation_projects.dat ]; then
+ source "$git_directory/translation_projects.dat"
+else
+ echo -e "\E[31m"
+ echo "Please set check_updates=1 in your configuration file first or copy"
+ echo "translation_projects.dat into $git_directory/ before running this"
+ echo "script again."
+ echo -e "\E[m"
+ exit 2
+fi
-echo "SW files:" | tee -a "$logfile"_this_run.log
+echo "LIST OF RESOURCES WITH FUZZY OR EMPTY STRINGS (in $language_code language)" > "$log_directory"/list_of_resources_for_translation.txt
+
+# clone / pull git repositories
+echo -e "\E[32m"
+echo "Clone / pull git repositories:" | tee -a "$logfile"_this_run.log
+echo -e "\E[m"
+for git_address in "${!git_addresses[@]}"
+do
+ echo $separator | tee -a "$logfile"_this_run.log
+ if [ -d "$git_directory/$git_address" ]; then
+ echo Pull git repository "${git_addresses[$git_address]}" to "$git_address". | tee -a "$logfile"_this_run.log
+ cd "$git_directory/$git_address"
+# just echo $language_code.po or *.pot file line if they are updated
+ git pull --stat --rebase | grep -E "$language_code.po$|.pot$|.desktop$|.html$" | tee -a "$logfile"_this_run.log
+# git diff --name-status ORIG_HEAD.. | grep -E "$language_code.po|[\.]pot"
+ else
+ echo Clone git repository "${git_addresses[$git_address]}" to "$git_address". | tee -a "$logfile"_this_run.log
+ cd "$git_directory/"
+# echo "${git_addresses[$git_address]}" # debug
+ git clone -q --single-branch mga:${git_addresses[$git_address]} $git_address | tee -a "$logfile"_this_run.log
+# cd "$git_directory/$git_address"
+ fi
+
+done
+echo $separator | tee -a "$logfile"_this_run.log
+echo "" | tee -a "$logfile"_this_run.log
+
+echo -e "\E[32m"
+echo "" >> "$log_directory"/list_of_resources_for_translation.txt
+echo "Po and pot files:" | tee -a "$logfile"_this_run.log
+echo "Translate po files in working directories ($working_translations_directory/):" >> "$log_directory"/list_of_resources_for_translation.txt
+echo -e "\E[m"
# 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."
+ echo "Syntax of $language_code.po in git 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."
+ echo "Files *.pot and $language_code.po will be copied into apropriate directory."
fi
-for project_name in "${!projects[@]}"
+for translate_project_name_po in "${!translate_projects_po[@]}"
do
echo $separator | tee -a "$logfile"_this_run.log
- echo Working on: \'$project_name\' from \'${projects[$project_name]}\'. | tee -a "$logfile"_this_run.log
-
-# 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
-# echo -n "" # debug
+ unexisted_po="no"
+ translate_this="no"
+ statistics_git_po=""
+ statistics_wd_po=""
+ pot_filename="*.pot"
+ echo "Working on $language_code.po file in working translations directory: $translate_project_name_po and local git directory: ${translate_projects_po[$translate_project_name_po]}." | tee -a "$logfile"_this_run.log
+ if [ ! -d "$git_directory/${translate_projects_po[$translate_project_name_po]}/" ]; then
+ echo "Directory $git_directory/${translate_projects_po[$translate_project_name_po]}/ doesn't exist."
+ echo "It seems that something wen't wrong in git clone operation. Other operations in $translate_project_name_po will be aborted."
+ echo "All operations in $translate_project_name_po was aborted! Check script output or logs." >> "$log_directory"/list_of_resources_for_translation.txt
+ continue
else
- 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_directory/$project_name"
+ cd "$git_directory/${translate_projects_po[$translate_project_name_po]}/" # $translate_project_name_po"
+ pot_filename=`ls *.pot`
+ wip_po_filename="$pot_filename"_$language_code.po
+ if [ $? -ne 0 ]; then
+ echo "Pot file not found in $git_directory/${translate_projects_po[$translate_project_name_po]}/. Please report that on our mailing list." | tee -a "$logfile"_this_run.log
+ fi
fi
-# verbose checking for fuzzy and untranslated strings
- if [ $check_fuzzy_and_untranslated -eq 1 ]; then
- msgattrib $language_code.po --only-fuzzy --no-obsolete
- msgattrib $language_code.po --untranslated --no-obsolete
+# checking for fuzzy and untranslated strings in git $language_code.po
+ if [ -f $language_code.po ]; then
+ msgattrib $language_code.po --only-fuzzy --no-obsolete | grep . >> /dev/null
+ if [ $? -eq 0 ]; then
+ translate_this="yes"
+ fi
+ msgattrib $language_code.po --untranslated --no-obsolete | grep . >> /dev/null
+ if [ $? -eq 0 ]; then
+ translate_this="yes"
+ fi
+ else # $language_code.po not in git yet
+ translate_this="yes"
+ fi
+ # creating statistics
+ if [ -f $language_code.po ]; then
+ statistics_git_po=`msgfmt --statistics --verbose $language_code.po -o /dev/null 2>&1 | tail -1`
+ fi
+ if [ -f $pot_filename ]; then
+ statistics_git_pot=`msgfmt --statistics --verbose $pot_filename -o /dev/null 2>&1 | tail -1`
fi
-# checking the syntax of po file if required
+# checking the syntax of po file from git if required
if [ $check_po_syntax -eq 1 ]; then
if [ -f $language_code.po ]; then
msgfmt --statistics --verbose -c $language_code.po -o /dev/null 2>&1 | tee -a "$logfile"_this_run.log
- else
- echo "File $language_code.po is not present in $project_name. Automatic test is not possible." | tee -a "$logfile"_this_run.log
+ else # Automatic test is not possible.
+ echo "File $language_code.po is not present yet in ${translate_projects_po[$translate_project_name_po]} for msgfmt test. Please translate it and commit & push it to git." | tee -a "$logfile"_this_run.log
+ unexisted_po="yes"
fi
-# checking the syntax of po file if required
+# checking the syntax of pot file from git if required
if [ $check_pot_syntax -eq 1 ]; then
- if [ -f *.pot ]; then
- msgfmt -c *.pot -o /dev/null 2>&1 | tee -a "$logfile"_this_run.log
- else
- echo "File *.pot is not present in $project_name. Automatic test is not possible." | tee -a "$logfile"_this_run.log
+ if [ -f $pot_filename ]; then
+ msgfmt -c $pot_filename -o /dev/null 2>&1 | tee -a "$logfile"_this_run.log
+ else # Automatic test is not possible.
+ echo "File *.pot is not present in ${translate_projects_po[$translate_project_name_po]}. Please report that on our mailing list." | tee -a "$logfile"_this_run.log
fi
fi
fi
# 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_directory/$project_name/" ]; then
- mkdir -vp "$working_translations_directory/$project_name/" | tee -a "$logfile"_this_run.log
+ if [ ! -d "$working_translations_directory/$translate_project_name_po/" ]; then
+ mkdir -vp "$working_translations_directory/$translate_project_name_po/" | 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_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
+ if [ "$unexisted_po" != "yes" ]; then
+# testing for differences of *.po file from git and working copy
+ if [ -f "$working_translations_directory/$translate_project_name_po/$language_code.po" ]; then
+ diff -q "$git_directory/${translate_projects_po[$translate_project_name_po]}/"$language_code.po "$working_translations_directory/$translate_project_name_po/$language_code.po" | tee -a "$logfile"_this_run.log
fi
- cp $copy_options $language_code.po "$working_translations_directory/$project_name/" | tee -a "$logfile"_this_run.log
+ cp $copy_options $language_code.po "$working_translations_directory/$translate_project_name_po/" | 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
+# echo "File $language_code.po is not present yet in ${translate_projects_po[$translate_project_name_po]}. Copying to working directory is not possible." | tee -a "$logfile"_this_run.log
+ echo -n # nop
fi
- if [ -f *.pot ]; then
-# testing for differences of *.pot file from working copy
- if [ -f "$working_translations_directory/$project_name/"*.pot ]; then
- diff -q *.pot "$working_translations_directory/$project_name/"*.pot | tee -a "$logfile"_this_run.log
+ if [ -f $pot_filename ]; then
+# testing for differences of *.pot file from git and working copy
+ if [ -f "$working_translations_directory/$translate_project_name_po/$pot_filename" ]; then
+ diff -q "$git_directory/${translate_projects_po[$translate_project_name_po]}/$pot_filename" "$working_translations_directory/$translate_project_name_po/$pot_filename" | tee -a "$logfile"_this_run.log
fi
- 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_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
+ cp $copy_options $pot_filename "$working_translations_directory/$translate_project_name_po/" | tee -a "$logfile"_this_run.log
+ cd "$working_translations_directory/$translate_project_name_po/"
+# rm sl.po # debug
+ if [ -f "$working_translations_directory/$translate_project_name_po/$wip_po_filename" ]; then
+# creating new_pot_lang.po from latest *.pot file
+ msgmerge -q $wip_po_filename $pot_filename > new_pot_$language_code.po | tee -a "$logfile"_this_run.log # || rm new_pot_$language_code.po # msgmerge *.pot_lang.po *.pot > new_pot_lang.po
+ if [ ${PIPESTATUS[0]} -ne 0 ]; then
+ msgfmt -c "$git_directory/${translate_projects_po[$translate_project_name_po]}/$pot_filename" -o /dev/null
+ if [ ${PIPESTATUS[0]} -ne 0 ]; then
+ echo Test with msgfmt -c discovered a problem with "$git_directory/${translate_projects_po[$translate_project_name_po]}/$pot_filename" file. | tee -a "$logfile"_this_run.log
+ echo Please report on our mailing list that msgfmt -c test has a problem with "$translate_project_name_po/$pot_filename" file. >> "$log_directory"/list_of_resources_for_translation.txt
+ fi
+ msgfmt -c "$git_directory/${translate_projects_po[$translate_project_name_po]}/"$language_code.po -o /dev/null
+ if [ ${PIPESTATUS[0]} -ne 0 ]; then
+ echo Test with msgfmt -c discovered a problem with "$git_directory/${translate_projects_po[$translate_project_name_po]}/"$language_code.po file. | tee -a "$logfile"_this_run.log
+ echo Test with msgfmt -c discovered a problem with $language_code.po file. Check script output or logs. >> "$log_directory"/list_of_resources_for_translation.txt
+ fi
+ rm new_pot_$language_code.po # remove it as it's no good anyway
+ fi
# comparing new_pot_lang.po from working copy
- diff -q *.pot_$language_code.po new_pot_$language_code.po | tee -a "$logfile"_this_run.log
-# diff -q $language_code.po new_pot_$language_code.po | tee -a "$logfile"_this_run.log
- diff_exit_status_1=${PIPESTATUS[0]} # this reads and remembers exit status of first command in pipe (diff in this case)
-# if [ $? -eq 0 ]; then
- if [ $diff_exit_status_1 -eq 0 ]; then # no differences
- rm new_pot_$language_code.po # remove resulting file
-# echo Between *.pot_$language_code.po and new_pot_$language_code.po there are no differences.
- else
- if [ $diff_exit_status_1 -eq 1 ]; then # there are differences
- echo Replace existing file *.pot_$language_code.po with new_pot_$language_code.po in $project_name since there are differences. | tee -a "$logfile"_this_run.log
+ if [ -f new_pot_$language_code.po ]; then
+ statistics_wd_po=`msgfmt --statistics --verbose new_pot_$language_code.po -o /dev/null 2>&1 | tail -1`
+ # checking for fuzzy and untranslated strings in fresh new_pot_$language_code.po
+ msgattrib new_pot_$language_code.po --only-fuzzy --no-obsolete 2>&1 | grep . >> /dev/null
+ if [ $? -eq 0 ]; then
+ translate_this="yes"
+ fi
+ msgattrib new_pot_$language_code.po --untranslated --no-obsolete 2>&1 | grep . >> /dev/null
+ if [ $? -eq 0 ]; then
+ translate_this="yes"
+ fi
+ diff -q $wip_po_filename new_pot_$language_code.po >> /dev/null #| tee -a "$logfile"_this_run.log
+# diff -q $language_code.po new_pot_$language_code.po | tee -a "$logfile"_this_run.log
+ diff_exit_status_1=${PIPESTATUS[0]} # this reads and remembers exit status of first command in pipe (diff in this case)
+# if [ $? -eq 0 ]; then
+ if [ $diff_exit_status_1 -eq 0 ]; then # no differences
+ rm new_pot_$language_code.po # remove resulting file
+# echo There are no differences between $wip_po_filename and new_pot_$language_code.po. # debug
else
- echo There was an error in diff between *.pot_$language_code.po and new_pot_$language_code.po in $project_name.
+ if [ $diff_exit_status_1 -eq 1 ]; then # there are differences
+ echo Replace existing file $wip_po_filename with new_pot_$language_code.po in working directory $translate_project_name_po since they differ. | tee -a "$logfile"_this_run.log
+ else
+ echo There was an error in diff between $wip_po_filename and new_pot_$language_code.po in working directory $translate_project_name_po.
+ fi
fi
+ else
+# echo There is no new_pot_$language_code.po. # debug
+ echo -n # nop
fi
-# comparing svn lang.po from working copy lang.po
+# comparing git lang.po from working copy lang.po
if [ -f $language_code.po ]; then
- diff -q *.pot_$language_code.po $language_code.po | tee -a "$logfile"_this_run.log
+ diff -q $wip_po_filename $language_code.po | tee -a "$logfile"_this_run.log
diff_exit_status_2=${PIPESTATUS[0]} # this reads and remembers exit status of first command in pipe (diff in this case)
# if [ $? -eq 0 ]; then
if [ $diff_exit_status_2 -eq 1 ]; then # there are differences
- echo New commit will be needed when the file *.pot_$language_code.po is ready in $project_name. | tee -a "$logfile"_this_run.log
+ echo New commit will be needed when the file $wip_po_filename will be ready in working directory $translate_project_name_po. | tee -a "$logfile"_this_run.log
else
if [ $diff_exit_status_2 -eq 2 ]; then # there was an error
- echo There was an error in diff between file *.pot_$language_code.po and $language_code.po in $project_name.
+ echo There was an error in diff between file $wip_po_filename and $language_code.po in working directory $translate_project_name_po.
fi
fi
fi
else
- echo "File *.pot_$language_code.po is not present in $project_name. Comparing is not possible." | tee -a "$logfile"_this_run.log
+ if [ "$unexisted_po" != "yes" ]; then
+ echo "File $wip_po_filename is not present in working directory $translate_project_name_po. Comparing is not possible." | tee -a "$logfile"_this_run.log
+ fi
+ if [ -z "$create_a_working_copy_of_po_file" ]; then
+ if [ "$unexisted_po" != "yes" ]; then
+ cp $copy_options $language_code.po $wip_po_filename | tee -a "$logfile"_this_run.log
+ echo "File $language_code.po in working directory $translate_project_name_po copied to $wip_po_filename." | tee -a "$logfile"_this_run.log
+ else
+ cp $copy_options $pot_filename $wip_po_filename | tee -a "$logfile"_this_run.log
+ echo "Template file $pot_filename in working directory $translate_project_name_po copied to $wip_po_filename." | tee -a "$logfile"_this_run.log
+ fi
+ fi
fi
-# set +x # turn tracing off with set +x
else
- echo "File *.pot is not present in $project_name. Copying is not possible." | tee -a "$logfile"_this_run.log
+ echo "File $pot_filename is not present in ${translate_projects_po[$translate_project_name_po]}. Copying is not possible." | tee -a "$logfile"_this_run.log
fi
-# echo "Files *.pot and $language_code.po copied into $working_translations_directory/$project_name/."
+# echo "Files *.pot and $language_code.po copied into $working_translations_directory/$translate_project_name_po/."
+ fi
+ if [ -n "$statistics_wd_po" ]; then
+ statistics_po=$statistics_wd_po
+ else
+ statistics_po=$statistics_git_po
+ fi
+ if [ -n "$statistics_po" ]; then
+ statistics=$statistics_po
+ else
+ statistics=$statistics_git_pot
+ fi
+ if [ "$translate_this" = "yes" ]; then
+ echo $translate_project_name_po, $statistics >> "$log_directory"/list_of_resources_for_translation.txt
+ fi
+# cd "$git_directory/"
+# echo "" | tee -a "$logfile"_this_run.log
+done
+echo "" | tee -a "$logfile"_this_run.log
+
+echo -e "\E[32m"
+echo "" >> "$log_directory"/list_of_resources_for_translation.txt
+echo "*.desktop files:" | tee -a "$logfile"_this_run.log
+echo "Translate *.desktop files in working directories ($working_translations_directory/desktop/$translate_project_name_desktop):" >> "$log_directory"/list_of_resources_for_translation.txt
+echo -e "\E[m"
+for translate_project_name_desktop in "${!translate_projects_desktop[@]}"
+do
+ if [ ! -f "$git_directory/${translate_projects_desktop[$translate_project_name_desktop]}" ]; then
+ echo "File $git_directory/${translate_projects_desktop[$translate_project_name_desktop]} doesn't exist."
+ echo "It seems that something wen't wrong in git clone operation. Other operations in $translate_project_name_desktop will be aborted."
+ echo "All operations in $translate_project_name_desktop was aborted! Check script output or logs." >> "$log_directory"/list_of_resources_for_translation.txt
+ continue
+ fi
+ echo $separator | tee -a "$logfile"_this_run.log
+ copy_this_desktop_file="no"
+ untranslated_name="Name, "
+ untranslated_comment="Comment,"
+ echo "Working on *.desktop file in working translations directory: $translate_project_name_desktop and local git directory: ${translate_projects_desktop[$translate_project_name_desktop]}." | tee -a "$logfile"_this_run.log
+# cd "$git_directory/${translate_projects_desktop[$translate_project_name_desktop]}/" # $translate_project_name_desktop"
+ names_and_comments=`cat "$git_directory/${translate_projects_desktop[$translate_project_name_desktop]}" #| grep -E "^Name=|^Name\[$language_code\]=|^Comment=|^Comment\[$language_code\]="`
+# echo names_and_comments: "$names_and_comments" # debug
+ eng_name=`echo "$names_and_comments" | grep -E "^Name=" | sed 's/^Name=//'`
+ lang_name=`echo "$names_and_comments" | grep -E "^Name\[$language_code\]=" | sed 's/^Name\['$language_code'\]=//'`
+ eng_comment=`echo "$names_and_comments" | grep -E "^Comment=" | sed 's/^Comment=//'`
+ lang_comment=`echo "$names_and_comments" | grep -E "^Comment\[$language_code\]=" | sed 's/^Comment\['$language_code'\]=//'`
+
+ if [ -n "$eng_name" ]; then # Name string present in original desktop file
+ if [ -n "$lang_name" ]; then # Name string present in your language
+ if [ "$lang_name" != "$eng_name" ]; then # both strings differ
+# echo Name string \"$eng_name\" present in $language_code language: \"$lang_name\" # debug
+# echo -n # nop
+ untranslated_name=""
+ else # both strings are equal
+ copy_this_desktop_file="yes"
+ echo Name string \"$eng_name\" in $language_code language present but untranslated | tee -a "$logfile"_this_run.log
+ fi
+ else # Name string not present in your language
+ copy_this_desktop_file="yes"
+ echo Name string \"$eng_name\" not present in $language_code language | tee -a "$logfile"_this_run.log
+ fi
+ fi
+ if [ -n "$eng_comment" ]; then # Comment string present in original desktop file
+ if [ -n "$lang_comment" ]; then # Comment string present in your language
+ if [ "$lang_comment" != "$eng_comment" ]; then # both strings differ
+# echo Comment string \"$eng_comment\" in $language_code language present: \"$lang_comment\" # debug
+# echo -n # nop
+ untranslated_comment=""
+ else # both strings are equal
+ copy_this_desktop_file="yes"
+ echo Comment string \"$eng_comment\" in $language_code language present but untranslated | tee -a "$logfile"_this_run.log
+ fi
+ else # Comment string not present in your language
+ copy_this_desktop_file="yes"
+ echo Comment string \"$eng_comment\" not present in $language_code language | tee -a "$logfile"_this_run.log
+ fi
+ fi
+
+# copying the *.desktop file for editing in working directory if required
+ if [ -z $copying_desktop_files ]; then
+ if [ "$copy_this_desktop_file" = "yes" ]; then
+ if [ ! -d "$working_translations_directory/desktop/$translate_project_name_desktop/" ]; then
+ mkdir -vp "$working_translations_directory/desktop/$translate_project_name_desktop/" | tee -a "$logfile"_this_run.log
+ fi
+ cp $copy_options "$git_directory/${translate_projects_desktop[$translate_project_name_desktop]}" "$working_translations_directory/desktop/$translate_project_name_desktop/" | tee -a "$logfile"_this_run.log
+ fi
+ fi
+ if [ "$copy_this_desktop_file" = "yes" ]; then
+ echo $translate_project_name_desktop, untranslated line: $untranslated_name $untranslated_comment >> "$log_directory"/list_of_resources_for_translation.txt
fi
- cd "$svn_directory/"
- echo "" | tee -a "$logfile"_this_run.log
done
+
# Check out / update web_page files
-echo "web page files:" | tee -a "$logfile"_this_run.log
+echo -e "\E[32m"
+echo "Check out / update web page files:" | tee -a "$logfile"_this_run.log
+echo "" >> "$log_directory"/list_of_resources_for_translation.txt
+echo "Please check http://www.mageia.org/langs/report.php for details about translation of web page files in $language_code language." >> "$log_directory"/list_of_resources_for_translation.txt
+echo -e "\E[m"
for web_page_name in "${!web_pages[@]}"
do
echo $separator | tee -a "$logfile"_this_run.log
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_directory/$web_page_name/" ]; then
- cd "$svn_directory/$web_page_name"
+ 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
+ svn up | grep -E "$language_code.lang|en.lang|.php" | tee -a "$logfile"_this_run.log
# echo -n "" # debug
else
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
+ 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_directory/$web_page_name"
+ cd "$svn_directory/$web_page_name/"
fi
- echo "" | tee -a "$logfile"_this_run.log
+# echo "" | tee -a "$logfile"_this_run.log
done
#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 -e "\E[32m"
echo "Web files will be copied (updated) into working translations directory."
- cd "$svn_directory"
+ echo -e "\E[m"
+ 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
@@ -297,8 +524,6 @@ if [ $copying_wp -eq 1 ]; then
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
if [ -d "$svn_directory/web_page_navigation/" ]; then
if [ -d "$svn_directory/web_page_navigation_2/" ]; then
@@ -311,41 +536,60 @@ else
fi
echo "" | tee -a "$logfile"_this_run.log
+cd "$git_directory/"
+##################################### TODO START change searching for new *.pot files and other resources in git
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
- 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
- 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
+ if [ "when_this_works_on_git" = "true" ]; then
+ echo $separator | tee -a "$logfile"_this_run.log
+ echo -e "\E[32m"
+ echo "Searching for new *.pot files in svn." | tee -a "$logfile"_this_run.log
+ echo -e "\E[m"
+ 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
+ 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
- echo "" | tee -a "$logfile"_this_run.log
fi
-
+##################################### TODO END
# append this_run_log to full_log
cat "$logfile"_this_run.log >> "$logfile"_full.log
echo "" | tee -a "$logfile".log
echo $separator | 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
- echo -e "\E["$color_for_differences"m"
- diff "$logfile"_this_run.log "$logfile"_previous_run.log | tee -a "$logfile".log
- echo -e "\E[m"
+if [ -z "$stop_showing_differences_from_last_run" ]; then
+ if [ -f "$logfile"_previous_run.log ]; then
+ # show only differences and log them
+ echo -e "\E[32m"
+ echo "Differences from last run:" | tee -a "$logfile".log
+ echo -e "\E[m"
+ echo -e "\E["$color_for_differences"m"
+ diff "$logfile"_this_run.log "$logfile"_previous_run.log | tee -a "$logfile".log
+ echo -e "\E[m"
+ fi
fi
+echo $separator
+echo -e "\E[33m"
+#echo "List of resources for translation:"
+cat "$log_directory"/list_of_resources_for_translation.txt
+echo -e "\E[m"
+
# 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"
-pwd
+# pwd
+# set -x # turn debug tracing on with set -x
+# set +x # turn debug tracing off with set +x
+exit 0