diff options
Diffstat (limited to 'tools/rebuild_gettext_catalogs.sh')
-rwxr-xr-x | tools/rebuild_gettext_catalogs.sh | 149 |
1 files changed, 0 insertions, 149 deletions
diff --git a/tools/rebuild_gettext_catalogs.sh b/tools/rebuild_gettext_catalogs.sh deleted file mode 100755 index 1c7b9e34e..000000000 --- a/tools/rebuild_gettext_catalogs.sh +++ /dev/null @@ -1,149 +0,0 @@ -#!/bin/bash -# Filip Komar, 2014 -# @license GPL v2 -# @author Filip (rebuilding a gettext dictionaries) -# @copyright 2014/03 -# inspired by check_for_translation_work.sh - -error=0 -declare -A resources -declare -A errors -if [ -f ./tools/web_projects.dat ]; then - source ./tools/web_projects.dat -else - echo Critical error!!! It was not possible to load web projects database! -fi - -for resource in "${!resources[@]}" -do - difference= - if [ "$resource" = "mognase" ]; then # is it about navigation? - path_and_filename=./_nav/langs/en - else - path_and_filename=./langs/en/$resource - fi - if [ -f $path_and_filename.pot ]; then # do a temporary copy - cp $path_and_filename.pot $path_and_filename.copy - fi - php_source=${resources[$resource]} - php tools/extract2gettext.php "$php_source" $resource true - php_error_level=$? # catch php error level - errors[$php_source]=$php_error_level - if [ -f $path_and_filename.pot ]; then - # msgmerge check of generated pot file - msgmerge --quiet --no-wrap $path_and_filename.pot $path_and_filename.pot --output-file=$path_and_filename.tmp - msgmerge_error_level=$? # catch msgmerge error level - if [ $msgmerge_error_level -gt 0 ]; then # on failure stop the process for this resource - errors[$php_source]=$msgmerge_error_level - rm $path_and_filename.tmp - fi - if [ -f $path_and_filename.copy ] && [ -f $path_and_filename.tmp ]; then - diff --ignore-matching-lines='^"POT-Creation-Date:' $path_and_filename.tmp $path_and_filename.copy - if [ $? -eq 1 ]; then # there are differences - errors[$php_source]=0 - mv $path_and_filename.tmp $path_and_filename.pot - rm $path_and_filename.copy - echo Changes in $path_and_filename.pot - else # Cleanup as there are no changes in $resource - errors[$php_source]=5 - rm $path_and_filename.tmp - mv $path_and_filename.copy $path_and_filename.pot - difference=none - fi - else # diff not possible - if [ -f $path_and_filename.tmp ]; then - mv $path_and_filename.tmp $path_and_filename.pot - if [ -f $path_and_filename.copy ]; then - rm $path_and_filename.copy - fi - else - rm $path_and_filename.pot - if [ -f $path_and_filename.copy ]; then - mv $path_and_filename.copy $path_and_filename.pot - difference=none - fi - fi - fi - if [ "$resource" = "mognase" ]; then # is it about navigation? - # create po files if needed from lang files if available - if [ -f ./_nav/langs/en.lang ]; then - python tools/translated_converter.py --filename ./_nav/langs/ - python_error_level=$? # catch python error level - if [ $python_error_level -gt 0 ]; then - errors[$resource]=50 - fi - if [ -f ./_nav/langs/en.po ]; then - rm ./_nav/langs/en.po - fi - fi - - for tr_file in ./_nav/langs/*.po - do - if [ -z $difference ]; then # update po file if needed -# msgfmt --statistics --verbose -c $tr_file -o /dev/null # usefull for debuging (msgctxt "/web/en/ or msgctxt "en/) - echo merging $tr_file - msgmerge --quiet --no-wrap $tr_file ./_nav/langs/en.pot --output-file=$tr_file.tmp - msgmerge_error_level=$? # catch msgmerge error level - if [ $msgmerge_error_level -gt 0 ]; then - errors[$directory/$resource]=60 - echo "$directory"/$resource.po could not be created succesfully - if [ -f $tr_file.tmp ]; then - rm $tr_file.tmp - fi - else - mv $tr_file.tmp $tr_file -# msgfmt --statistics --verbose -c $tr_file -o /dev/null # usefull for debuging (msgctxt "/web/en/ or msgctxt "en/) - fi - fi - done - else - for directory in ./langs/* - do - # in each language directory except source - if [ -d $directory/ ] && [ $directory != ./langs/en ]; then - # create po file if needed from lang file if available - if [ ! -f $directory/$resource.po ] && [ -f $directory/$resource.*.lang ]; then -# echo $directory # usefull for debuging of non UTF-8 files or other python errors - python tools/translated_converter.py --filename $directory/$resource - python_error_level=$? # catch python error level - if [ $python_error_level -gt 0 ]; then - errors[$directory/$resource]=50 - fi - fi - 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/$resource.po - msgmerge --quiet --no-wrap $directory/$resource.po ./langs/en/$resource.pot --output-file=$directory/$resource.tmp - msgmerge_error_level=$? # catch msgmerge error level - if [ $msgmerge_error_level -gt 0 ]; then - errors[$directory/$resource]=60 - echo "$directory"/$resource.po could not be created succesfully - if [ -f $tr_file.tmp ]; then - rm $directory/$resource.tmp - fi - else - 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/) - fi - fi - fi - done - fi - fi -done - -echo '' -#printf "%s\n" "${errors[@]}" -for error_in_source in "${!errors[@]}" -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." ;; - 50) echo "!!!! Script translated_converter.py encounter an error in $error_in_source !!!!" ;; - 60) echo "$error_in_source.po could not be created succesfully!! Duplicates?" ;; - esac -done |