[pacman-dev] [PATCH] Gettext support in pacman-optimize
Add gettext support to pacman-optimize. Signed-off-by: Giovanni Scafora <linuxmania@gmail.com> diff --git a/scripts/pacman-optimize b/scripts/pacman-optimize index ca17033..5b5a836 100755 --- a/scripts/pacman-optimize +++ b/scripts/pacman-optimize @@ -20,6 +20,14 @@ # USA. # +# gettext initialization" +source gettext.sh + +TEXTDOMAIN=pacman-optimize +export TEXTDOMAIN +TEXTDOMAINDIR='@localedir@' +export TEXTDOMAINDIR + myver='3.0.0' error() { @@ -34,18 +42,19 @@ source /etc/rc.conf #for USECOLOR source /etc/rc.d/functions usage() { - echo "pacman-optimize $myver" - echo "usage: $0 [pacman_db_root]" + echo "$(gettext "pacman-optimize %s")" $myver + local msg=$0; shift + printf "$(gettext "usage: \$msg [pacman_db_root]")" $* echo - echo "pacman-optimize is a little hack that should improve the performance" - echo "of pacman when reading/writing to its filesystem-based database." + echo "$(gettext "pacman-optimize is a little hack that should improve the performance")" + echo "$(gettext "of pacman when reading/writing to its filesystem-based database.")" echo - echo "Because pacman uses many small files to keep track of packages," - echo "there is a tendency for these files to become fragmented over time." - echo "This script attempts to relocate these small files into one" - echo "continuous location on your hard drive. The result is that the hard" - echo "drive should be able to read them faster, since the hard drive head" - echo "does not have to move around the disk as much." + echo "$(gettext "Because pacman uses many small files to keep track of packages,")" + echo "$(gettext "there is a tendency for these files to become fragmented over time.")" + echo "$(gettext "This script attempts to relocate these small files into one")" + echo "$(gettext "continuous location on your hard drive. The result is that the hard")" + echo "$(gettext "drive should be able to read them faster, since the hard drive head")" + echo "$(gettext "does not have to move around the disk as much.")" echo } @@ -71,64 +80,64 @@ fi # make sure pacman isn't running if [ -f /tmp/pacman.lck ]; then - die "Pacman lockfile was found. Cannot run while pacman is running." + die "$(gettext "Pacman lockfile was found. Cannot run while pacman is running.")" fi if [ ! -d "$dbroot" ]; then - die "$dbroot does not exist or is not a directory" + die "$(gettext "%s does not exist or is not a directory")" $dbroot fi if [ ! -w "$dbroot" ]; then - die "You must have correct permissions to optimize the database" + die "$(gettext "You must have correct permissions to optimize the database")" fi # do not let pacman run while we do this touch /tmp/pacman.lck # step 1: sum the old db -stat_busy "Md5sum'ing the old database" +stat_busy "$(gettext "Md5sum'ing the old database")" find $dbroot -type f | sort | xargs md5sum > /tmp/pacsums.old stat_done # step 2: tar it up -stat_busy "Tar'ing up $dbroot" +stat_busy "$(gettext "Tar'ing up %s")" $dbroot cd $dbroot tar -czf /tmp/pacmanDB.tgz ./ if [ $? -ne 0 ]; then stat_fail rm -f /tmp/pacmanDB.tgz /tmp/pacsums.old - die_r "tar'ing up $dbroot failed" + die_r "$(gettext "tar'ing up %s failed")" $dbroot fi stat_done # step 3: make and sum the new db -stat_busy "Making and md5sum'ing the new db" +stat_busy "$(gettext "Making and md5sum'ing the new db")" mkdir $dbroot.new tar -zxpf /tmp/pacmanDB.tgz -C $dbroot.new/ if [ $? -ne 0 ]; then rm -f /tmp/pacmanDB.tgz /tmp/pacsums.old rm -rf "$dbroot.new" - die_r "untar'ing $dbroot failed" + die_r "$(gettext "untar'ing %s failed")" $dbroot fi find "$dbroot.new" -type f | sort | sed -e 's/pacman.new/pacman/g' |\ xargs md5sum > /tmp/pacsums.new stat_done # step 4: compare the sums -stat_busy "Checking integrity" +stat_busy "$(gettext "Checking integrity")" diff /tmp/pacsums.old /tmp/pacsums.new >/dev/null 2>&1 if [ $? -ne 0 ]; then # failed stat_fail # leave /tmp/pacsums.old and .new for checking to see what doesn't match up rm -rf "$dbroot.new" /tmp/pacman.lck /tmp/pacmanDB.tgz - die_r "integrity check FAILED, reverting to old database" + die_r "$(gettext "integrity check FAILED, reverting to old database")" fi stat_done # step 5: remove the new temporary database and the old one # and use the .tgz to replace the old one -stat_busy "Putting the new database in place" +stat_busy "$(gettext "Putting the new database in place")" rm -rf "$dbroot.new" "$dbroot"/* tar -zxpf /tmp/pacmanDB.tgz -C "$dbroot"/ stat_done @@ -137,7 +146,7 @@ stat_done rm -f /tmp/pacman.lck /tmp/pacsums.old /tmp/pacsums.new /tmp/pacmanDB.tgz echo -echo "Finished. Your pacman database has been optimized." +echo "$(gettext "Finished. Your pacman database has been optimized.")" echo exit 0 -- 1.5.0.6 -- Giovanni Scafora Arch Linux Trusted User (voidnull) http://www.archlinux.org linuxmania@gmail.com
participants (1)
-
Giovanni Scafora