3.2. Changes to configure.in

There are a number of changes required to configure.in. You need to test for the existence of intltool, set up a few definitions for use at build time and list the languages for which you have translations. The code to do all of this is given in the next example. I have listed it all in one block, although traditionally, the intltool detection comes early in the configure.in and the rest of the tests go together at some point later in the file.

Example 7. Text to be added to configure.in

AC_PROG_INTLTOOL([0.23])

GETTEXT_PACKAGE=slice-n-dice
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE")

ALL_LINGUAS=""
AM_GLIB_GNU_GETTEXT

slicelocaledir='${prefix}/${DATADIRNAME}/locale'
AC_SUBST(slicelocaledir)

A couple of items need explanatson here. Firstly, the three lines dealing with GETTEXT_PACKAGE are used to define the message domain for this application and make it available both to the makefiles that are generated and also as a #define to the source code (this is done in the AC_DEFINE_UNQUOTED() macro). Recall from earlier, that the i18n support was initialised by a call to bindtextdomain() using GETTEXT_PACKAGE as the name.

Secondly, I have created an empty ALL_LINGUAS string, since no translations yet exist. One you have some translations available, you would add their language codes to ALL_LINGUAS. This variable is a string of space separated language codes, so after adding a few languages, it might look like this

ALL_LINGUAS="de en_AU no sv"

Thirdly, the AC_PROG_INTLTOOL macro takes an optional argument specifying the minimal version required. I have specified verison 0.23 in this code fragment, since that is the first version that extracts the default key values in Gconf schemas correctly. If you do not need this particular feature, it is safe to specify version 0.21, since that is widely available and works mostly correctly.

Finally, I define a variable called slicelocaledir (you may change this name to anything you like) which specifies where the locale files will be installed. In the Makefile.am changes I will get to in the next section, this variable will be passed into each file as it is built and will be used in the bindtextdomain() call to initialise the i18n support. You may think that this should be done automatically, but this construction is required in order to make things build seamlessly on Solaris installations, where message files are stored in a slightly different location to that assumed by GNU's gettext.

The last change required in configure.in is to go to the end of the file and add the file po/Makefile.in to the list of files generated by the AC_OUPUT macro.

At this point your application should still build without problems. However, the i18n support will still be disabled (since no languages are present and AM_GLIB_GNU_GETTEXT is not called). Furthermore, even if languages were available, they would not be applied to a lot of the files that intltool manages, since we have not made the necessary build changes in the makefiles. That is the next step.