gettext 0.11.x compatibility
Christian Hammond <[email protected]>
| Newsgroups | gmane.comp.web.galeon.devel |
|---|---|
| Organization | The GNUpdate Project (http://www.gnupdate.org/) |
| Message-ID | <[email protected]> |
I was looking through the ChangeLog and noticed an attempt at gettext 0.11.x compatibility. Having gone through a lot of fights with gettext, I thought I'd point to a script I devised that provides gettext 0.10.x and 0.11.x compatibility, mostly painlessly. It's available at http://www.chipx86.com/linuxstuff/gettext/ and is used by Anjuta, Enlightenment, Gaim, GNUpdate, and a couple other projects. Hmm, this is starting to sound like an advertisement, but I think it may prove useful anyway. I have supplied a patch against the galeon-1-2 branch that adds support for setup-gettext, as well as the setup-gettext script (which I have in the root of the tree, but if moved, you just update the SETUP_GETTEXT variable in macros/autogen.sh). I hope it can be of some help. Christian -- Christian Hammond <> The GNUpdate Project [email protected] <> http://www.gnupdate.org/ Isn't is it a bit unnerving that doctors call what they do "practice"?
setup-gettext
(text/plain, 5.2 KB)
#!/bin/sh
#
# setup-gettext - Provides compatibility with versions of gettext
# from the 0.10.x series and 0.11.x.
#
# Copyright (C) 2002 Christian Hammond.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
VERSION=0.1.3
VERBOSE=0
parse_gettext_version() {
GETTEXT_VERSION=`$GETTEXT_TOOL --version | sed -n 's/^.*\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\).*$/\1.\2.\3/p'`
GETTEXT_MAJOR_VERSION=`echo $GETTEXT_VERSION | sed -n 's/^\([0-9]\+\).*/\1/p'`
GETTEXT_MINOR_VERSION=`echo $GETTEXT_VERSION | sed -n 's/^[0-9]\+\.\([0-9]\+\).*/\1/p'`
GETTEXT_MICRO_VERSION=`echo $GETTEXT_VERSION | sed -n 's/^[0-9]\+\.[0-9]\+\.\([0-9]\+\).*/\1/p'`
}
find_gettext() {
GETTEXT_TOOL=autopoint
(autopoint --version) < /dev/null > /dev/null 2>&1 || {
GETTEXT_TOOL=gettextize
(gettextize --version) < /dev/null > /dev/null 2>&1 || {
GETTEXT_TOOL=
}
}
}
install() {
[ -f configure.in ] && {
cp configure.in .tmp-configure.in
sed -e 's/^AM_GNU_GETTEXT\(.*\)$/AM_GNU_GETTEXT\1\
AM_GNU_GETTEXT_VERSION(0.10.40)/' < .tmp-configure.in > configure.in
rm .tmp-configure.in
}
[ -f configure.ac ] && {
cp configure.ac .tmp-configure.ac
sed -e 's/^AM_GNU_GETTEXT\(.*\)$/AM_GNU_GETTEXT\1\
AM_GNU_GETTEXT_VERSION(0.10.40)/' < .tmp-configure.ac > configure.ac
rm .tmp-configure.ac
}
[ -f autogen.sh ] && {
cp autogen.sh .tmp-autogen.sh
sed -e 's/\(gettextize\|autopoint\) --version/.\/setup-gettext --gettext-tool/1' -e 's/^\(echo.*|[\t ]*\)\?\(gettextize\|autopoint\) -.*$/.\/setup-gettext/1' < .tmp-autogen.sh > autogen.sh
rm .tmp-autogen.sh
}
echo 'AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])' >> acinclude.m4
}
backup_m4() {
[ -d m4 ] && mv m4 m4~
}
restore_m4() {
[ -d m4~ ] && {
rm -rf m4
mv m4~ m4
}
}
restore_files() {
[ -f configure.in~ ] && mv -f configure.in~ configure.in
[ -f configure.ac~ ] && mv -f configure.ac~ configure.ac
[ -f Makefile.am~ ] && mv -f Makefile.am~ Makefile.am
}
abort() {
restore_files
restore_m4
exit 1
}
# Main code
find_gettext
# See if a version of gettext and its tools are installed.
if [ x$GETTEXT_TOOL = x ]; then
echo
echo "You do not have a version of gettext installed."
echo "Please download one from your local package repository or"
echo "from ftp://ftp.gnu.org/pub/gnu/gettext/"
echo
exit 1
fi
parse_gettext_version
NUMVAR=$#
if [ $NUMVAR -gt 0 ]; then
if [ $NUMVAR -gt 1 ]; then
echo "Only one option at a time!"
exit 1
elif [ $1 = "--gettext-tool" ]; then
echo $GETTEXT_TOOL
exit 0
elif [ $1 = "--help" ]; then
echo "setup-gettext v$VERSION"
echo "Usage:"
echo " --gettext-tool Returns gettextize or autopoint, depending"
echo " on the version of gettext installed."
echo " --gettext-version Returns the version of gettext installed."
echo " --gettext-major-version Returns the major version of gettext installed."
echo " --gettext-minor-version Returns the minor version of gettext installed."
echo " --gettext-micro-version Returns the micro version of gettext installed."
echo " --help Displays this help screen."
echo
exit 0
elif [ $1 = "--version" ]; then
echo $VERSION
exit 0
elif [ $1 = "--gettext-version" ]; then
echo $GETTEXT_VERSION
exit 0
elif [ $1 = "--gettext-major-version" ]; then
echo $GETTEXT_MAJOR_VERSION
exit 0
elif [ $1 = "--gettext-minor-version" ]; then
echo $GETTEXT_MINOR_VERSION
exit 0
elif [ $1 = "--gettext-micro-version" ]; then
echo $GETTEXT_MICRO_VERSION
exit 0
elif [ $1 = "--install" ]; then
install
echo "setup-gettext installed."
exit 0
elif [ $1 = "--happy-url" ]; then
echo http://gaim.sf.net/forkgettext.jpg
exit 0
elif [ $1 = "--verbose" ]; then
VERBOSE=1
else
echo "Invalid option '$1'"
exit 1
fi
fi
# Okay, run the main stuff
if [ "$GETTEXT_TOOL" = "autopoint" ]; then
backup_m4
[ $VERBOSE -eq 1 ] && echo " autopoint --force"
echo n | autopoint --force || abort
restore_m4
else
if [ $GETTEXT_MINOR_VERSION -eq 11 ]; then
backup_m4
# Gettext is pure evil. It DEMANDS that we press Return no matter
# what. This gets rid of their happy "feature" of doom.
[ $VERBOSE -eq 1 ] && \
echo " gettextize --copy --force --intl --no-changelog"
sed 's:read .*< /dev/tty::' `which gettextize` > .temp-gettextize
chmod +x .temp-gettextize
echo n | ./.temp-gettextize --copy --force --intl --no-changelog || abort
rm .temp-gettextize
restore_files
restore_m4
[ -f po/Makevars.template ] && mv po/Makevars.template po/Makevars
else
[ $VERBOSE -eq 1 ] && echo " gettextize --copy --force"
echo n | gettextize --copy --force || exit;
fi
fi
setup-gettext.diff
(text/plain, 3.3 KB)
Index: configure.in
===================================================================
RCS file: /cvs/gnome/galeon/configure.in,v
retrieving revision 1.241.2.32
diff -u -r1.241.2.32 configure.in
--- configure.in 28 Nov 2002 02:17:07 -0000 1.241.2.32
+++ configure.in 29 Nov 2002 02:04:01 -0000
@@ -610,6 +610,7 @@
dnl Add the languages which your application supports here.
ALL_LINGUAS="az bg ca cs da de el es et fi fr gl hr hu it ja ko lt lv ms nl nn no pl pt pt_BR ro ru sk sl sv ta tr uk vi wa zh_CN zh_TW"
AM_GNU_GETTEXT
+AM_GNU_GETTEXT_VERSION(0.10.40)
dnl Set PACKAGE_LOCALE_DIR in config.h.
if test "x${prefix}" = "xNONE"; then
Index: macros/autogen.sh
===================================================================
RCS file: /cvs/gnome/galeon/macros/Attic/autogen.sh,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 autogen.sh
--- macros/autogen.sh 23 Nov 2002 08:37:08 -0000 1.1.2.3
+++ macros/autogen.sh 29 Nov 2002 02:04:01 -0000
@@ -3,6 +3,8 @@
DIE=0
+SETUP_GETTEXT=./setup-gettext
+
if [ -n "$GNOME2_PATH" ]; then
ACLOCAL_FLAGS="-I $GNOME2_PATH/share/aclocal $ACLOCAL_FLAGS"
PATH="$GNOME2_PATH/bin:$PATH"
@@ -47,16 +49,16 @@
}
}
-#grep "^AM_GNU_GETTEXT" $srcdir/configure.in >/dev/null && {
-# grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \
-# (gettext --version) < /dev/null > /dev/null 2>&1 || {
-# echo
-# echo "**Error**: You must have \`gettext' installed to compile $PKG_NAME."
-# echo "Get ftp://ftp.gnu.org/pub/gnu/gettext/gettext-0.10.39.tar.gz"
-# echo "(or a newer version if it is available)"
-# DIE=1
-# }
-#}
+grep "^AM_GNU_GETTEXT" $srcdir/configure.in >/dev/null && {
+ grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \
+ ($SETUP_GETTEXT --gettext-tool) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`gettext' installed to compile $PKG_NAME."
+ echo "Get ftp://ftp.gnu.org/pub/gnu/gettext/gettext-0.10.39.tar.gz"
+ echo "(or a newer version if it is available)"
+ DIE=1
+ }
+}
#grep "^AM_GNOME_GETTEXT" $srcdir/configure.in >/dev/null && {
# grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \
@@ -96,7 +98,7 @@
if test -z "$*"; then
echo "**Warning**: I am going to run \`configure' with no arguments."
echo "If you wish to pass any to it, please specify them on the"
- echo \`$0\'" command line."
+# echo \`$0\'" command line."
echo
fi
@@ -105,11 +107,6 @@
am_opt=--include-deps;;
esac
-# get gettextize version to see if we must supply the --intl flag
-if gettextize --version | grep 0.11. >/dev/null; then
- INTLFLAG=--intl
-fi
-
for coin in `find $srcdir -name configure.in -print`
do
dr=`dirname $coin`
@@ -150,7 +147,7 @@
echo "Creating $dr/aclocal.m4 ..."
test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
echo "Running gettextize... Ignore non-fatal messages."
- echo "no" | gettextize --force --copy $INTLFLAG
+ $SETUP_GETTEXT
echo "Making $dr/aclocal.m4 writable ..."
test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
fi
@@ -159,7 +156,7 @@
echo "Creating $dr/aclocal.m4 ..."
test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
echo "Running gettextize... Ignore non-fatal messages."
- echo "no" | gettextize --force --copy $INTLFLAG
+ $SETUP_GETTEXT
echo "Making $dr/aclocal.m4 writable ..."
test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
fi