[pacman-dev] [PATCH] Gettext support in gensync
Add gettext support to gensync. Signed-off-by: Giovanni Scafora <linuxmania@gmail.com> diff --git a/scripts/gensync b/scripts/gensync index f99cf59..fa88f32 100755 --- a/scripts/gensync +++ b/scripts/gensync @@ -20,28 +20,37 @@ # 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 "$(eval_gettext "gensync \$myver")" + gensync=$0 + echo "$(eval_gettext "usage: \$gensync <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 @@ -83,7 +92,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 +111,9 @@ if [ "$3" != "" ]; then pkgdir="$3" fi -[ ! -d "$rootdir" ] && die "invalid root dir: $rootdir" +[ ! -d "$rootdir" ] && die "$(eval_gettext "invalid root dir: \$rootdir")" -echo "gensync: building database entries, generating md5sums..." >&2 +echo "$(gettext "gensync: building database entries, generating md5sums...")" >&2 cd "$destdir" pkgs="" @@ -113,7 +122,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 "$(eval_gettext "failed to parse parse \$file")" if [ "$pkgdir" != "" ]; then pkgfile="$pkgdir/$pkgname-$pkgver-$pkgrel-$CARCH.$PKGEXT" else @@ -121,7 +130,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 "$(eval_gettext "could not find \$pkgname-\$pkgver-\$pkgrel-\$CARCH.\$PKGEXT - skipping")" else if check_force; then forcepkgs="$forcepkgs $pkgfile" @@ -131,7 +140,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@gmail.com
Giovanni Scafora wrote:
Add gettext support to gensync.
Signed-off-by: Giovanni Scafora <linuxmania@gmail.com>
diff --git a/scripts/gensync b/scripts/gensync index f99cf59..fa88f32 100755 --- a/scripts/gensync +++ b/scripts/gensync @@ -20,28 +20,37 @@ # USA. #
+# gettext initialization" +source gettext.sh + +TEXTDOMAIN=gensync +export TEXTDOMAIN +TEXTDOMAINDIR='@localedir@' +export TEXTDOMAINDIR +
Is there any reason why we can't use a common TEXTDOMAIN for all the scripts. I think with a little tidying up we'll find that there's a lot of standard messages in the scripts, and it would be easier for translators to maintain if it was all in the same .mo file. Also Dan reminded me you can't use $() and $1 in eval_gettext, so to make life easier we might want to use printf instead of echo in the output functions. eg from abs error "$(eval_gettext "invalid root dir: \$rootdir")" would become error "$(gettext "invalid root dir: %s")" $rootdir and change the output functions to something like local msg=$1; shift printf "==> ERROR: $msg\n" $* Andrew
On 4/2/07, Andrew Fyfe <andrew@neptune-one.net> wrote:
Giovanni Scafora wrote:
Add gettext support to gensync.
Signed-off-by: Giovanni Scafora <linuxmania@gmail.com>
diff --git a/scripts/gensync b/scripts/gensync index f99cf59..fa88f32 100755 --- a/scripts/gensync +++ b/scripts/gensync @@ -20,28 +20,37 @@ # USA. #
+# gettext initialization" +source gettext.sh + +TEXTDOMAIN=gensync +export TEXTDOMAIN +TEXTDOMAINDIR='@localedir@' +export TEXTDOMAINDIR +
Is there any reason why we can't use a common TEXTDOMAIN for all the scripts. I think with a little tidying up we'll find that there's a lot of standard messages in the scripts, and it would be easier for translators to maintain if it was all in the same .mo file.
Yes, this is something I forgot in my last email. We definitely want to have one textdomain, which will more than likely be 'pacman'. There are still quite a few details to work out with regards to translations- adding the gettext calls is only part of the issue. More than likely our po directory will need to move to the root of the checkout. -Dan
On 4/2/07, Giovanni Scafora <linuxmania@gmail.com> wrote:
Add gettext support to gensync.
Signed-off-by: Giovanni Scafora <linuxmania@gmail.com>
I don't want to burst your efforts here- but gensync is in some ways a depreciated script and repo-add is much preferred. I don't know if we should add this to it, but then again, there isn't a real compelling reason against it. -Dan
participants (3)
-
Andrew Fyfe
-
Dan McGee
-
Giovanni Scafora