Firstly, ensure that your autogen.sh script will be able to bootstrap the whole process by locating the glib-gettextize script and then running it. If you leverage the autogen.sh script from the gnome-common module in GNOME's CVS repository, this is all done automatically for you and you can skip forwards to the next section.
If you are not using the standard GNOME autogen.sh script, you will need to add a check for the appropriate scripts and then run whatever you found. Here is some sample code that does this (checking for both a form of gettextize and for intltool.
You may not be able to use this code directly — it depends upon how you have structured your autogen.sh script. These examples assume an autogen.sh of a form used commonly in gnome (such as in the gnome-common module and some standalone scripts like those in Gconf and metacity.
You may also wish to look at the autogen.sh (and corresponding acinclude.m4 files) from glib or gtk+. Those packages are much more self-contained and force the use of glib-gettextize. However, they are vastly different from the standard scripts used in other parts of GNOME.
Example 5. Additions to autogen.sh
if grep "^AM_[A-Z0-9_]\{1,\}_GETTEXT" "$CONFIGURE" >/dev/null; then
if grep "sed.*POTFILES" "$CONFIGURE" >/dev/null; then
GETTEXTIZE=""
else
if grep "^AM_GLIB_GNU_GETTEXT" "$CONFIGURE" >/dev/null; then
GETTEXTIZE="glib-gettextize"
else
GETTEXTIZE="gettextize"
fi
$GETTEXTIZE --version < /dev/null > /dev/null 2>&1
if test $? -ne 0; then
echo
echo "**Error**: You must have \`$GETTEXTIZE' installed" \
"to compile $PKG_NAME."
DIE=1
fi
fi
fi
(grep "^AC_PROG_INTLTOOL" "$CONFIGURE" >/dev/null) && {
(intltoolize --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`intltoolize' installed" \
"to compile $PKG_NAME."
DIE=1
}
}
|
Later on in autogen.sh, before running libtoolize or any of those scripts, you should bootstrap the i18n process by running glib-gettextize and intltoolize like this:
Example 6. Further additions to autogen.sh
if test "$GETTEXTIZE"; then echo "Creating $dr/aclocal.m4 ..." test -r aclocal.m4 || touch aclocal.m4 echo "Running $GETTEXTIZE... Ignore non-fatal messages." echo "no" | $GETTEXTIZE --force --copy echo "Making aclocal.m4 writable ..." test -r aclocal.m4 && chmod u+w aclocal.m4 fi if grep "^AC_PROG_INTLTOOL" $bn >/dev/null; then echo "Running intltoolize..." intltoolize --copy --force --automake fi |
A certain amount of customisation might be needed here if, for example, aclocal.m4 was not in the current directory. For best results, copy an example from an existing application, such as Gconf.
The reason for using glib-gettextize instead of the more natural gettextize is due to a difference in philosophy between the GNU maintainers of gettext and GNOME developers. The gettext maintainers argue that a script like gettextize should only be run when migrating between versions of gettext or when initially preparing a project for using gettext. In GNOME, however, we prefer not to store the files generated by glib-gettextize (which are essentially the same as those generated by gettextize) in CVS and just to generate them at autogen time. The two ways of working cannot be met by a single script, so the GNOME project uses a slightly changed version of the original gettext script.
In version 0.11 of gettext a script called autopoint has been introduced, which plays a similar role to glib-gettextize. However, GNOME does not currently require gettext version 0.11, so it would be premature to rely on that script.