diff options
author | Filip Komar <filip@mageia.org> | 2014-03-11 22:00:55 +0000 |
---|---|---|
committer | Filip Komar <filip@mageia.org> | 2014-03-11 22:00:55 +0000 |
commit | d9f9613fdaba65f16c4e9c4116ea107cf4889504 (patch) | |
tree | 87a7b47a3b2dc3c0861c98c4307fa8f942543ac8 | |
parent | 326eac8a3d1f926f2707ad1de61818a97f6f8dbe (diff) | |
download | www-d9f9613fdaba65f16c4e9c4116ea107cf4889504.tar www-d9f9613fdaba65f16c4e9c4116ea107cf4889504.tar.gz www-d9f9613fdaba65f16c4e9c4116ea107cf4889504.tar.bz2 www-d9f9613fdaba65f16c4e9c4116ea107cf4889504.tar.xz www-d9f9613fdaba65f16c4e9c4116ea107cf4889504.zip |
do not regenerate pot and po files if there are no changes in the source
-rw-r--r-- | langs/en/404.pot | 2 | ||||
-rw-r--r-- | langs/en/about/reports.pot | 2 | ||||
-rw-r--r-- | tools/extract2gettext.php | 3 | ||||
-rwxr-xr-x | tools/rebuild_gettext_catalogs.sh | 36 |
4 files changed, 28 insertions, 15 deletions
diff --git a/langs/en/404.pot b/langs/en/404.pot index 443390de1..fcbbcdc5f 100644 --- a/langs/en/404.pot +++ b/langs/en/404.pot @@ -3,7 +3,7 @@ # This file is distributed under the same license as # the content of the corresponding web page(s). # -# Generated by extract2gettext.php on 2014-03-10 21:59:38+0000 +# Generated by extract2gettext.php # Domain: 404 # # include translation strings from: diff --git a/langs/en/about/reports.pot b/langs/en/about/reports.pot index 1f2ec2266..6ac600daf 100644 --- a/langs/en/about/reports.pot +++ b/langs/en/about/reports.pot @@ -3,7 +3,7 @@ # This file is distributed under the same license as # the content of the corresponding web page(s). # -# Generated by extract2gettext.php on 2014-03-10 21:59:37+0000 +# Generated by extract2gettext.php # Domain: about/reports # # include translation strings from: 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." ;; |