3.3. Makefile changes

Firstly, edit the top-level Makefile.am and add po to the list of subdirectories to be descended into. So you would have a line that looks something like

SUBDIRS = src po

Also, add intltool-extract.in, intltool-merge.in and intltool-update.in to the EXTRA_DIST rule in the top-level Makefile.am. Add these three filename, plus the same names without the .in extension to your .cvsignore in that directory.

Then change to the directory containing the file with your main() function or library initialisation code. You need to edit the include flags in the Makefile.am for that directory and add a line to set up the directory for storing the message files.

INCLUDES =                      \
    -I$(top_srcdir)             \
    ...
    -DSLICELOCALEDIR=\""$(slicelocaledir)"\"

Here, SLICELOCALEDIR matches the variable name you passed to the bindtextdomain() call (see Section 2.1.2, “Initialising the i18n support code”) and slicelocaledir matches the variable name you chose when editing configure.in in the previous section.

The final piece of makefile editing required is to allow intltool to build fully translated versions of your desktop, schema, server and XML files. Back in Section 2.2, “Marking translatable strings”, you created a number of new files with .in extensions and special markup to indicate fields that are to be translated. Every one of those files (without the .in extension) currently appears in some Makefile.am. It will appear in a line like

desktop_DATA = slice-n-dice.desktop

You need to edit this to generate this file from the template file with the help of intltool. For the above example, we would change the Makefile.am to read

desktop_in_files = slice-n-dice.desktop.in
desktop_DATA = $(slice_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@

There are two changes involved here. Firstly, we now list all the desktop files (only one in this case, but you may have more) under a different name (one that is not special to Automake). Then the desktop_DATA rule works out what files it contains by applying a transformation pattern to the files in the earlier list.

The second change is the inclusion of some special makefile rules which take care of merging any available translations into slice-n-dice.desktop.in to create slice-n-dice.desktop. These rules are included using the @INTLTOOL_DESKTOP_RULE@ variable, which is substituted as part of the AC_PROG_INTLTOOL macro in configure.in.

Everything is similar for server, schema and generic XML files, except that @INTLTOOL_DESKTOP_RULE@ is replaced with @INTLTOOL_SERVER_RULE@, @INTLTOOL_SCHEMAS_RULE@ and @INTLTOOL_XML_RULE@ respectively. You will also need to change the target that holds the filenames as well (the one called desktop_DATA above). You may have different targets for your desktop, schema, server and XML files. There are some more examples of how to make these changes in the README file that comes with the intltool distribution.

Once you have made all these Makefile.am changes, you can remove the original desktop, etc, files (the ones without the .in extensions), since they are now generated automatically. You will also probably want to add the generated names to your .cvsignore files in the respective directories so that cvs does not complain about these newly created, unknown files.