diff options
Diffstat (limited to 'check_for_translation_work.sh')
-rwxr-xr-x | check_for_translation_work.sh | 792 |
1 files changed, 396 insertions, 396 deletions
diff --git a/check_for_translation_work.sh b/check_for_translation_work.sh index 2f1b3947..12eb76c6 100755 --- a/check_for_translation_work.sh +++ b/check_for_translation_work.sh @@ -7,16 +7,16 @@ # # Filip Komar, 2012, 2013 # Remco Rijnders, 2012 -# $Id: check_for_translation_work.sh 2013-11-01 22:19:00 UTC filip $ +# $Id: check_for_translation_work.sh 2013-11-02 13:28:00 UTC filip $ # # 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 + source ~/.mageia-i18n-config else - cat > ~/.mageia-i18n-config << "EOF" + cat > ~/.mageia-i18n-config << "EOF" # Please change the below values to match your needs: language_code=xx @@ -102,44 +102,44 @@ color_for_differences=31 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." - echo -e "\E[m" - exit 1 + 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." + 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 + 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 saved_dir=$(pwd) if [ -f "$logfile"_this_run.log ]; then - mv "$logfile"_this_run.log "$logfile"_previous_run.log + mv "$logfile"_this_run.log "$logfile"_previous_run.log fi separator="-----------------------------------------------------" +# Check if directories exist and create them if not if [ -z "$work_on_web_pages_translation" ]; then - # Check if directories exist and create them if not - if [ ! -d "$svn_directory" ]; then - mkdir -vp "$svn_directory/" # | tee -a "$logfile"_this_run.log - fi + if [ ! -d "$svn_directory" ]; then + mkdir -vp "$svn_directory/" # | tee -a "$logfile"_this_run.log + fi fi if [ ! -d "$git_directory" ]; then - mkdir -vp "$git_directory/" # | tee -a "$logfile"_this_run.log + 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 + mkdir -vp "$working_translations_directory/" | tee -a "$logfile"_this_run.log fi echo "" | tee -a "$logfile"_this_run.log @@ -147,26 +147,26 @@ date | tee -a "$logfile"_this_run.log # Check if a newer version of this script is available. If yes, show the changes. if [ $check_updates -eq 1 ]; then - if [ -f "$git_directory"/translation_projects.dat ]; then - cp "$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 - cp "$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 - echo "" + if [ -f "$git_directory"/translation_projects.dat ]; then + cp "$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 + cp "$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 + echo "" fi declare -A git_addresses @@ -175,14 +175,14 @@ declare -A translate_projects_desktop declare -A translate_projects_help declare -A web_pages if [ -f "$git_directory"/translation_projects.dat ]; then - source "$git_directory/translation_projects.dat" + 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 + 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 "LIST OF RESOURCES WITH FUZZY OR EMPTY STRINGS (in $language_code language)" > "$log_directory"/list_of_resources_for_translation.txt @@ -193,20 +193,20 @@ 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 + 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 @@ -218,194 +218,194 @@ 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 +# echo about checking the syntax of po file if required if [ $check_po_syntax -eq 1 ]; then - echo "Syntax of $language_code.po in git 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 +# 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 translate_project_name_po in "${!translate_projects_po[@]}" do - echo $separator | tee -a "$logfile"_this_run.log - 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 "$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 - -# 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 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 # 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 pot file from git if required - if [ $check_pot_syntax -eq 1 ]; then - 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/$translate_project_name_po/" ]; then - mkdir -vp "$working_translations_directory/$translate_project_name_po/" | tee -a "$logfile"_this_run.log - fi - 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/$translate_project_name_po/" | tee -a "$logfile"_this_run.log - else -# 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_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_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 - 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 - 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 git lang.po from working copy lang.po - if [ -f $language_code.po ]; then - 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 $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 $wip_po_filename and $language_code.po in working directory $translate_project_name_po. - fi - fi - fi - else - 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 - else - 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/$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 + echo $separator | tee -a "$logfile"_this_run.log + 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 "$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 + +# 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 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 # 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 pot file from git if required + if [ $check_pot_syntax -eq 1 ]; then + 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/$translate_project_name_po/" ]; then + mkdir -vp "$working_translations_directory/$translate_project_name_po/" | tee -a "$logfile"_this_run.log + fi + 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/$translate_project_name_po/" | tee -a "$logfile"_this_run.log + else +# 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_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_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 + 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 + 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 git lang.po from working copy lang.po + if [ -f $language_code.po ]; then + 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 $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 $wip_po_filename and $language_code.po in working directory $translate_project_name_po. + fi + fi + fi + else + 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 + else + 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/$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 @@ -416,154 +416,154 @@ echo "Translate *.desktop files in working directories ($working_translations_di 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 + 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 done if [ -z "$work_on_web_pages_translation" ]; then - # Check out / update web_page files - 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 # \' - 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_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_directory/$web_page_name/" - fi - # 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." - 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 - 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 - - 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 +# Check out / update web_page files + 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 # \' + 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_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_directory/$web_page_name/" + fi +# 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." + 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 + 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 + + 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 fi 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 - 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 + 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 fi ##################################### TODO END @@ -573,20 +573,20 @@ echo "" | tee -a "$logfile".log echo $separator | tee -a "$logfile".log 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 + 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:" +# echo "List of resources for translation:" cat "$log_directory"/list_of_resources_for_translation.txt echo -e "\E[m" |