[pacman-dev] [PATCH] Fixed gettext support in gensync
Giovanni Scafora
linuxmania at gmail.com
Mon Apr 2 12:18:50 EDT 2007
Let's me know if it's correct now.
Fixed gettext support to gensync after Andrew's email.
Signed-off-by: Giovanni Scafora <linuxmania at gmail.com>
diff --git a/scripts/gensync b/scripts/gensync
index f99cf59..2250c23 100755
--- a/scripts/gensync
+++ b/scripts/gensync
@@ -20,35 +20,45 @@
# USA.
#
+# gettext initialization"
+source gettext.sh
+
+TEXTDOMAIN=gensync
+export TEXTDOMAIN
+TEXTDOMAINDIR='@localedir@'
+export TEXTDOMAINDIR
+
myver='3.0.0'
# functions
usage() {
- echo "gensync $myver"
- echo "usage: $0 <root> <destfile> [package_directory]"
+ echo "$(gettext "gensync %s")" $myver
+ local msg=$0; shift
+ printf "$(gettext "usage: \$msg <root> <destfile> [package_directory]")" $*
echo
- echo "gensync will generate a sync database by reading all PKGBUILD files"
- echo "from <root>. gensync builds the database in a temporary directory"
- echo "and then compresses it to <destfile>."
+ echo "$(gettext "gensync will generate a sync database by reading
all PKGBUILD files")"
+ echo "$(gettext "from <root>. gensync builds the database in a
temporary directory")"
+ echo "$(gettext "and then compresses it to <destfile>.")"
echo
- echo "gensync will calculate md5sums of packages in the same directory as"
- echo "<destfile>, unless an alternate [package_directory] is specified."
+ echo "$(gettext "gensync will calculate md5sums of packages in the
same directory as")"
+ echo "$(gettext "<destfile>, unless an alternate [package_directory]
is specified.")"
echo
- echo "note: The <destfile> name is important. It must be of the form"
- echo " {treename}.db.tar.gz where {treename} is the name of the custom"
- echo " package repository you configured in /etc/pacman.conf. The"
- echo " generated database must reside in the same directory as your"
- echo " custom packages (also configured in /etc/pacman.conf)"
+ echo "$(gettext "note: The <destfile> name is important. It must be
of the form")"
+ echo "$(gettext " {treename}.db.tar.gz where {treename} is the
name of the custom")"
+ echo "$(gettext " package repository you configured in
/etc/pacman.conf. The")"
+ echo "$(gettext " generated database must reside in the same
directory as your")"
+ echo "$(gettext " custom packages (also configured in
/etc/pacman.conf)")"
echo
- echo "example: gensync /var/abs/local /home/mypkgs/custom.db.tar.gz"
+ echo "$(gettext "example: gensync /var/abs/local
/home/mypkgs/custom.db.tar.gz")"
echo
echo
exit 0
}
error () {
- echo "==> ERROR: $*" >&2
+ local msg=$*; shift
+ printf "$(gettext "==> ERROR: \$msg")" $* >&2
}
die () {
@@ -83,7 +93,7 @@ fi
if [ -r /etc/makepkg.conf ]; then
source /etc/makepkg.conf
else
- echo "ERROR: /etc/makepkg.conf not found. Can not continue." >&2
+ echo "$(gettext "ERROR: /etc/makepkg.conf not found. Can not continue.")" >&2
exit 1 # $E_CONFIG_ERROR # TODO: error codes
fi
@@ -102,9 +112,9 @@ if [ "$3" != "" ]; then
pkgdir="$3"
fi
-[ ! -d "$rootdir" ] && die "invalid root dir: $rootdir"
+[ ! -d "$rootdir" ] && die "$(gettext "invalid root dir: %s")" $rootdir
-echo "gensync: building database entries, generating md5sums..." >&2
+echo "$(gettext "gensync: building database entries, generating
md5sums...")" >&2
cd "$destdir"
pkgs=""
@@ -113,7 +123,7 @@ forcepkgs=""
for file in $(find "$rootdir"/* -name "$BUILDSCRIPT"); do
unset pkgname pkgver pkgrel options
- source $file || die "failed to parse parse $file"
+ source $file || die "$(gettext "failed to parse parse %s")" $file
if [ "$pkgdir" != "" ]; then
pkgfile="$pkgdir/$pkgname-$pkgver-$pkgrel-$CARCH.$PKGEXT"
else
@@ -121,7 +131,7 @@ for file in $(find "$rootdir"/* -name "$BUILDSCRIPT"); do
fi
if [ ! -f "$pkgfile" ]; then
- error "could not find $pkgname-$pkgver-$pkgrel-$CARCH.$PKGEXT - skipping"
+ error "$(gettext "could not find %s-%s-%s-%s.%s - skipping")"
$pkgname $pkgver $pkgrel $CARCH $PKGEXT
else
if check_force; then
forcepkgs="$forcepkgs $pkgfile"
@@ -131,7 +141,7 @@ for file in $(find "$rootdir"/* -name "$BUILDSCRIPT"); do
fi
done
-echo "creating repo DB..."
+echo "$(gettext "creating repo DB...")"
# we'll trim the output just a tad, as gensync may be used on large repos
repo-add $destfile $pkgs --force $force_pkgs \
--
1.5.0.6
--
Giovanni Scafora
Arch Linux Trusted User (voidnull)
http://www.archlinux.org
linuxmania at gmail.com
More information about the pacman-dev
mailing list