SF.net SVN: postfixadmin: [264] trunk/languages/language-update.sh
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2007-12-06 22:37:04
|
Revision: 264 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=264&view=rev Author: christian_boltz Date: 2007-12-06 14:37:07 -0800 (Thu, 06 Dec 2007) Log Message: ----------- language-update.sh: - new parameter --addcomment - adds a comment to all *.lang files except en.lang Useful if a text has changed and needs to be re-translated. Modified Paths: -------------- trunk/languages/language-update.sh Modified: trunk/languages/language-update.sh =================================================================== --- trunk/languages/language-update.sh 2007-12-06 22:21:29 UTC (rev 263) +++ trunk/languages/language-update.sh 2007-12-06 22:37:07 UTC (rev 264) @@ -95,6 +95,33 @@ } # end rename_string() +function addcomment() { + for file in $filelist ; do + test "$file" = "en.lang" && { echo "*** skipping en.lang ***"; continue ; } >&2 + + line="$(grep "PALANG\['$text'\]" "$file")" || { + echo "*** $file does not contain \$PALANG['$text'] ***" >&2 + continue + } + + newline="$line # XXX $comment" + + # create patch + echo " +--- $file.old ++++ $file +@@ -1,1 +1,1 @@ +-$line ++$newline + " > "$file.patch" + + test $patch = 0 && cat $file.patch + test $patch = 1 && patch $file < $file.patch + done +} # end add_comment + + + function cleanup() { # check for duplicated strings for file in $filelist ; do @@ -171,6 +198,13 @@ Rename $PALANG['"'"'old_string'"'"'] to $PALANG['"'"'new_string'"'"'] +'"$0"' --addcomment string comment [--patch] [--nocleanup] [foo.lang [bar.lang [...] ] ] + + Add a comment to $PALANG['"'"'string'"'"'] + + Useful if a string needs to be translated again. + + '"$0"' --stats Print translation statistics to postfixadmin-languages.txt @@ -197,6 +231,9 @@ nocleanup=0 # don't delete tempfiles rename=0 # rename a string stats=0 # create translation statistics +addcomment=0 # add translation comment +text='' +comment='' rename_old='' renane_new='' filelist='' @@ -224,6 +261,14 @@ echo "$rename_new" | grep '^[a-z_-]*\.lang$' && rename_new='' # error out on *.lang - probably a filename test -z "$rename_new" && { echo '--rename needs two parameters' >&2 ; exit 1 ; } ;; + --addcomment) + addcomment=1 + shift ; text="$1" + shift ; comment="$1" + echo "$text" | grep '^[a-z_-]*\.lang$' && comment='' # error out on *.lang - probably a filename + echo "$comment" | grep '^[a-z_-]*\.lang$' && comment='' # error out on *.lang - probably a filename + test -z "$comment" && { echo '--addcomment needs two parameters' >&2 ; exit 1 ; } + ;; --stats) stats=1 ;; @@ -243,6 +288,7 @@ test "$filelist" = "" && filelist="`ls -1 *.lang`" +test "$addcomment" = 1 && { addcomment ; cleanup ; exit 0 ; } test "$rename" = 1 && { rename_string ; cleanup ; exit 0 ; } test "$stats" = 1 && { statistics ; exit 0 ; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |