From d9f9613fdaba65f16c4e9c4116ea107cf4889504 Mon Sep 17 00:00:00 2001 From: Filip Komar Date: Tue, 11 Mar 2014 22:00:55 +0000 Subject: do not regenerate pot and po files if there are no changes in the source --- tools/extract2gettext.php | 3 ++- tools/rebuild_gettext_catalogs.sh | 36 ++++++++++++++++++++++++------------ 2 files changed, 26 insertions(+), 13 deletions(-) (limited to 'tools') diff --git a/tools/extract2gettext.php b/tools/extract2gettext.php index 8eff15de0..1cbdb3a17 100644 --- a/tools/extract2gettext.php +++ b/tools/extract2gettext.php @@ -87,7 +87,8 @@ foreach ($strings as $domain => $strs) { $f[] = '# This file is distributed under the same license as'; $f[] = '# the content of the corresponding web page(s).'; $f[] = '#'; - $f[] = sprintf('# Generated by extract2gettext.php on %s', $cur_date = date('Y-m-d H:i:sO')); + $cur_date = date('Y-m-d H:i:sO'); + $f[] = '# Generated by extract2gettext.php'; $f[] = sprintf('# Domain: %s', $domain); $f[] = '#'; $f[] = '# include translation strings from:'; diff --git a/tools/rebuild_gettext_catalogs.sh b/tools/rebuild_gettext_catalogs.sh index 93e78c8df..afe8564af 100755 --- a/tools/rebuild_gettext_catalogs.sh +++ b/tools/rebuild_gettext_catalogs.sh @@ -16,16 +16,29 @@ fi for resource in "${!resources[@]}" do + if [ -f ./langs/en/$resource.pot ]; then # do a temporary copy + cp ./langs/en/$resource.pot ./langs/en/$resource.copy + fi php_source=${resources[$resource]} php tools/extract2gettext.php $php_source $resource true php_error_level=$? # catch php error level - error=$php_error_level - error_in_source=$php_source - errors[$php_source]=$php_sourc$php_error_level - if [ -f ./langs/en/$resource.pot ]; then # cut too long lines + errors[$php_source]=$php_error_level + if [ -f ./langs/en/$resource.pot ]; then # msgmerge check of generated pot file msgmerge --quiet --no-wrap ./langs/en/$resource.pot ./langs/en/$resource.pot > ./langs/en/$resource.tmp - mv ./langs/en/$resource.tmp ./langs/en/$resource.pot - + if [ -f ./langs/en/$resource.copy ]; then + diff --ignore-matching-lines='^"POT-Creation-Date:' ./langs/en/$resource.tmp ./langs/en/$resource.copy + if [ $? -eq 1 ]; then # there are differences + errors[$php_source]=0 + mv ./langs/en/$resource.tmp ./langs/en/$resource.pot + else # Cleanup as there are no changes in $resource + errors[$php_source]=5 + rm ./langs/en/$resource.tmp + mv ./langs/en/$resource.copy ./langs/en/$resource.pot + difference=none + fi + else + mv ./langs/en/$resource.tmp ./langs/en/$resource.pot + fi for directory in ./langs/* do # in each language directory except source @@ -36,21 +49,19 @@ do python tools/translated_converter.py --filename $directory/$resource python_error_level=$? # catch python error level if [ $python_error_level -gt 0 ]; then - error=50 - error_in_source=$directory/$resource + errors[$directory/$resource]=50 fi fi - if [ -f $directory/$resource.po ]; then # update po file if it exists + if [ -f $directory/$resource.po ] && [ -z $difference ]; then # update po file if it exists # msgfmt --statistics --verbose -c $directory/$resource.po -o /dev/null # usefull for debuging (msgctxt "/web/en/ or msgctxt "en/) + echo merging $directory msgmerge --quiet --no-wrap $directory/$resource.po ./langs/en/$resource.pot > $directory/$resource.tmp msgmerge_error_level=$? # catch msgmerge error level mv $directory/$resource.tmp $directory/$resource.po # msgfmt --statistics --verbose -c $directory/$resource.po -o /dev/null # usefull for debuging (msgctxt "/web/en/ or msgctxt "en/) if [ $msgmerge_error_level -gt 0 ]; then - error=60 - error_in_source=$directory/$resource + errors[$directory/$resource]=60 echo "$directory"/$resource.po could not be created succesfully - errors[$resource]=$resource$msgmerge_error_level fi fi fi @@ -65,6 +76,7 @@ do case ${errors[$error_in_source]} in 0) echo "Done lookup for _g() and _r() in $error_in_source. Gettext catalogs (pot files) rebuilded. Existing po files updated." ;; 1) echo "Unkown error!!" ;; + 5) echo "There are no changes in $error_in_source." ;; 10) echo "No strings to save from $error_in_source!" ;; 20) echo "!!!! Parse error, please fix $error_in_source first !!!! See details above." ;; 30) echo "!!!! Failed to write $error_in_source !!!! See details above." ;; -- cgit v1.2.1