diff options
author | Thomas Backlund <tmb@mageia.org> | 2014-10-12 12:27:45 +0300 |
---|---|---|
committer | Thomas Backlund <tmb@mageia.org> | 2014-10-12 12:27:45 +0300 |
commit | 9ce6d646ff718cd62f6434c9a4c94e450436612a (patch) | |
tree | 3ee82e5db7c0aee44a5573d9d17035c6ecac697d /tools/rebuild_gettext_catalogs.sh | |
parent | a0b2d09125d7911656fe4cb286f20643c4432281 (diff) | |
download | www-9ce6d646ff718cd62f6434c9a4c94e450436612a.tar www-9ce6d646ff718cd62f6434c9a4c94e450436612a.tar.gz www-9ce6d646ff718cd62f6434c9a4c94e450436612a.tar.bz2 www-9ce6d646ff718cd62f6434c9a4c94e450436612a.tar.xz www-9ce6d646ff718cd62f6434c9a4c94e450436612a.zip |
Revert "Updated Estonian translation"
This reverts commit a0b2d09125d7911656fe4cb286f20643c4432281.
Diffstat (limited to 'tools/rebuild_gettext_catalogs.sh')
-rwxr-xr-x | tools/rebuild_gettext_catalogs.sh | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/tools/rebuild_gettext_catalogs.sh b/tools/rebuild_gettext_catalogs.sh new file mode 100755 index 000000000..1c7b9e34e --- /dev/null +++ b/tools/rebuild_gettext_catalogs.sh @@ -0,0 +1,149 @@ +#!/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 |