This is gettext.info, produced by makeinfo version 4.0 from
gettext.texi.

INFO-DIR-SECTION GNU Gettext Utilities
START-INFO-DIR-ENTRY
* Gettext: (gettext).                           GNU gettext utilities.
* gettextize: (gettext)gettextize Invocation.   Prepare a package for gettext.
* msgfmt: (gettext)msgfmt Invocation.           Make MO files out of PO files.
* msgmerge: (gettext)msgmerge Invocation.       Update two PO files into one.
* xgettext: (gettext)xgettext Invocation.       Extract strings into a PO file.
END-INFO-DIR-ENTRY

   This file provides documentation for GNU `gettext' utilities.  It
also serves as a reference for the free Translation Project.

   Copyright (C) 1995, 1996, 1997, 1998, 2001, 2002 Free Software
Foundation, Inc.

   Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

   Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.

   Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that this permission notice may be stated in a
translation approved by the Foundation.


File: gettext.info,  Node: gettextize Invocation,  Next: Adjusting Files,  Prev: Prerequisites,  Up: Maintainers

Invoking the `gettextize' Program
=================================

   The `gettextize' program is an interactive tool that helps the
maintainer of a package internationalized through GNU `gettext'.  It is
used for two purposes:

   * As a wizard, when a package is modified to use GNU `gettext' for
     the first time.

   * As a migration tool, for upgrading the GNU `gettext' support in a
     package from a previous to a newer version of GNU `gettext'.

   This program performs the following tasks:

   * It copies into the package some files that are consistently and
     identically needed in every package internationalized through GNU
     `gettext'.

   * It performs as many of the tasks mentioned in the next section
     *Note Adjusting Files:: as can be performed automatically.

   * It removes obsolete files and idioms used for previous GNU
     `gettext' versions to the form recommended for the current GNU
     `gettext' version.

   * It prints a summary of the tasks that ought to be done manually
     and could not be done automatically by `gettextize'.

   It can be invoked as follows:

     gettextize [ OPTION... ] [ DIRECTORY ]

and accepts the following options:

`-c'
`--copy'
     Copy the needed files instead of making symbolic links.  Using
     links would allow the package to always use the latest `gettext'
     code available on the system, but it might disturb some mechanism
     the maintainer is used to apply to the sources.  Because running
     `gettextize' is easy there shouldn't be problems with using copies.

`-f'
`--force'
     Force replacement of files which already exist.

`--intl'
     Install the libintl sources in a subdirectory named `intl/'.  This
     libintl will be used to provide internationalization on systems
     that don't have GNU libintl installed. If this option is omitted,
     the call to `AM_GNU_GETTEXT' in `configure.in' should read:
     `AM_GNU_GETTEXT([external])', and internationalization will not be
     enabled on systems lacking GNU gettext.

`--no-changelog'
     Don't update or create ChangeLog files.  By default, `gettextize'
     logs all changes (file additions, modifications and removals) in a
     file called `ChangeLog' in each affected directory.

`-n'
`--dry-run'
     Print modifications but don't perform them.  All actions that
     `gettextize' would normally execute are inhibited and instead only
     listed on standard output.

`--help'
     Display this help and exit.

`--version'
     Output version information and exit.

   If DIRECTORY is given, this is the top level directory of a package
to prepare for using GNU `gettext'.  If not given, it is assumed that
the current directory is the top level directory of such a package.

   The program `gettextize' provides the following files.  However, no
existing file will be replaced unless the option `--force' (`-f') is
specified.

  1. The `ABOUT-NLS' file is copied in the main directory of your
     package, the one being at the top level.  This file gives the main
     indications about how to install and use the Native Language
     Support features of your program.  You might elect to use a more
     recent copy of this `ABOUT-NLS' file than the one provided through
     `gettextize', if you have one handy.  You may also fetch a more
     recent copy of file `ABOUT-NLS' from Translation Project sites,
     and from most GNU archive sites.

  2. A `po/' directory is created for eventually holding all
     translation files, but initially only containing the file
     `po/Makefile.in.in' from the GNU `gettext' distribution (beware
     the double `.in' in the file name) and a few auxiliary files. If
     the `po/' directory already exists, it will be preserved along
     with the files it contains, and only `Makefile.in.in' and the
     auxiliary files will be overwritten.

  3. Only if `--intl' has been specified: A `intl/' directory is
     created and filled with most of the files originally in the
     `intl/' directory of the GNU `gettext' distribution.  Also, if
     option `--force' (`-f') is given, the `intl/' directory is emptied
     first.

  4. The files `config.rpath' and `mkinstalldirs' are copied into the
     directory containing configuration support files. It is needed by
     the `AM_GNU_GETTEXT' autoconf macro.

  5. Only if the project is using GNU `automake': A set of `autoconf'
     macro files is copied into the package's `autoconf' macro
     repository, usually in a directory called `m4/'.

   If your site support symbolic links, `gettextize' will not actually
copy the files into your package, but establish symbolic links instead.
This avoids duplicating the disk space needed in all packages.  Merely
using the `-h' option while creating the `tar' archive of your
distribution will resolve each link by an actual copy in the
distribution archive.  So, to insist, you really should use `-h' option
with `tar' within your `dist' goal of your main `Makefile.in'.

   Furthermore, `gettextize' will update all `Makefile.am' files in
each affected directory, as well as the top level `configure.in' or
`configure.ac' file.

   It is interesting to understand that most new files for supporting
GNU `gettext' facilities in one package go in `intl/', `po/' and `m4/'
subdirectories.  One distinction between `intl/' and the two other
directories is that `intl/' is meant to be completely identical in all
packages using GNU `gettext', while the other directories will mostly
contain package dependent files.

   The `gettextize' program makes backup files for all files it
replaces or changes, and also write ChangeLog entries about these
changes.  This way, the careful maintainer can check after running
`gettextize' whether its changes are acceptable to him, and possibly
adjust them.  An exception to this rule is the `intl/' directory, which
is added or replaced or removed as a whole.

   It is important to understand that `gettextize' can not do the
entire job of adapting a package for using GNU `gettext'.  The amount
of remaining work depends on whether the package uses GNU `automake' or
not.  But in any case, the maintainer should still read the section
*Note Adjusting Files:: after invoking `gettextize'.

   It is also important to understand that `gettextize' is not part of
the GNU build system, in the sense that it should not be invoked
automatically, and not be invoked by someone who doesn't assume the
responsibilities of a package maintainer.  For the latter purpose, a
separate tool is provided, see *Note autopoint Invocation::.


File: gettext.info,  Node: Adjusting Files,  Next: autoconf macros,  Prev: gettextize Invocation,  Up: Maintainers

Files You Must Create or Alter
==============================

   Besides files which are automatically added through `gettextize',
there are many files needing revision for properly interacting with GNU
`gettext'.  If you are closely following GNU standards for Makefile
engineering and auto-configuration, the adaptations should be easier to
achieve.  Here is a point by point description of the changes needed in
each.

   So, here comes a list of files, each one followed by a description of
all alterations it needs.  Many examples are taken out from the GNU
`gettext' 0.11.5 distribution itself, or from the GNU `hello'
distribution (`http://www.franken.de/users/gnu/ke/hello' or
`http://www.gnu.franken.de/ke/hello/')  You may indeed refer to the
source code of the GNU `gettext' and GNU `hello' packages, as they are
intended to be good examples for using GNU gettext functionality.

* Menu:

* po/POTFILES.in::              `POTFILES.in' in `po/'
* po/LINGUAS::                  `LINGUAS' in `po/'
* po/Makevars::                 `Makefile' pieces in `po/'
* configure.in::                `configure.in' at top level
* config.guess::                `config.guess', `config.sub' at top level
* mkinstalldirs::               `mkinstalldirs' at top level
* aclocal::                     `aclocal.m4' at top level
* acconfig::                    `acconfig.h' at top level
* config.h.in::                 `config.h.in' at top level
* Makefile::                    `Makefile.in' at top level
* src/Makefile::                `Makefile.in' in `src/'
* lib/gettext.h::               `gettext.h' in `lib/'


File: gettext.info,  Node: po/POTFILES.in,  Next: po/LINGUAS,  Prev: Adjusting Files,  Up: Adjusting Files

`POTFILES.in' in `po/'
----------------------

   The `po/' directory should receive a file named `POTFILES.in'.  This
file tells which files, among all program sources, have marked strings
needing translation.  Here is an example of such a file:

     # List of source files containing translatable strings.
     # Copyright (C) 1995 Free Software Foundation, Inc.
     
     # Common library files
     lib/error.c
     lib/getopt.c
     lib/xmalloc.c
     
     # Package source files
     src/gettext.c
     src/msgfmt.c
     src/xgettext.c

Hash-marked comments and white lines are ignored.  All other lines list
those source files containing strings marked for translation (*note
Mark Keywords::), in a notation relative to the top level of your whole
distribution, rather than the location of the `POTFILES.in' file itself.

   When a C file is automatically generated by a tool, like `flex' or
`bison', that doesn't introduce translatable strings by itself, it is
recommended to list in `po/POTFILES.in' the real source file (ending in
`.l' in the case of `flex', or in `.y' in the case of `bison'), not the
generated C file.


File: gettext.info,  Node: po/LINGUAS,  Next: po/Makevars,  Prev: po/POTFILES.in,  Up: Adjusting Files

`LINGUAS' in `po/'
------------------

   The `po/' directory should also receive a file named `LINGUAS'.
This file contains the list of available translations.  It is a
whitespace separated list.  Hash-marked comments and white lines are
ignored.  Here is an example file:

     # Set of available languages.
     de fr

This example means that German and French PO files are available, so
that these languages are currently supported by your package.  If you
want to further restrict, at installation time, the set of installed
languages, this should not be done by modifying the `LINGUAS' file, but
rather by using the `LINGUAS' environment variable (*note Installers::).


File: gettext.info,  Node: po/Makevars,  Next: configure.in,  Prev: po/LINGUAS,  Up: Adjusting Files

`Makefile' pieces in `po/'
--------------------------

   The `po/' directory also has a file named `Makevars'.  It can be
left unmodified if your package has a single message domain and,
accordingly, a single `po/' directory. Only packages which have
multiple `po/' directories at different locations need to adjust the
three variables defined in `Makevars'.

   `po/Makevars' gets inserted into the `po/Makefile' when the latter
is created. At the same time, all files called `Rules-*' in the `po/'
directory get appended to the `po/Makefile'. They present an
opportunity to add rules for special PO files to the Makefile, without
needing to mess with `po/Makefile.in.in'.

   GNU gettext comes with a `Rules-quot' file, containing rules for
building catalogs `en@quot.po' and `en@boldquot.po'. The effect of
`en@quot.po' is that people who set their `LANGUAGE' environment
variable to `en@quot' will get messages with proper looking symmetric
Unicode quotation marks instead of abusing the ASCII grave accent and
the ASCII apostrophe for indicating quotations. To enable this catalog,
simply add `en@quot' to the `po/LINGUAS' file. The effect of
`en@boldquot.po' is that people who set `LANGUAGE' to `en@boldquot'
will get not only proper quotation marks, but also the quoted text will
be shown in a bold font on terminals and consoles. This catalog is
useful only for command-line programs, not GUI programs. To enable it,
similarly add `en@boldquot' to the `po/LINGUAS' file.


File: gettext.info,  Node: configure.in,  Next: config.guess,  Prev: po/Makevars,  Up: Adjusting Files

`configure.in' at top level
---------------------------

   `configure.in' or `configure.ac' - this is the source from which
`autoconf' generates the `configure' script.

  1. Declare the package and version.

     This is done by a set of lines like these:

          PACKAGE=gettext
          VERSION=0.11.5
          AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
          AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
          AC_SUBST(PACKAGE)
          AC_SUBST(VERSION)

     or, if you are using GNU `automake', by a line like this:

          AM_INIT_AUTOMAKE(gettext, 0.11.5)

     Of course, you replace `gettext' with the name of your package,
     and `0.11.5' by its version numbers, exactly as they should appear
     in the packaged `tar' file name of your distribution
     (`gettext-0.11.5.tar.gz', here).

  2. Check for internationalization support.

     Here is the main `m4' macro for triggering internationalization
     support.  Just add this line to `configure.in':

          AM_GNU_GETTEXT

     This call is purposely simple, even if it generates a lot of
     configure time checking and actions.

     If you have suppressed the `intl/' subdirectory by calling
     `gettextize' without `--intl' option, this call should read

          AM_GNU_GETTEXT([external])

  3. Have output files created.

     The `AC_OUTPUT' directive, at the end of your `configure.in' file,
     needs to be modified in two ways:

          AC_OUTPUT([EXISTING CONFIGURATION FILES intl/Makefile po/Makefile.in],
          [EXISTING ADDITIONAL ACTIONS])

     The modification to the first argument to `AC_OUTPUT' asks for
     substitution in the `intl/' and `po/' directories.  Note the `.in'
     suffix used for `po/' only.  This is because the distributed file
     is really `po/Makefile.in.in'.

     If you have suppressed the `intl/' subdirectory by calling
     `gettextize' without `--intl' option, then you don't need to add
     `intl/Makefile' to the `AC_OUTPUT' line.



File: gettext.info,  Node: config.guess,  Next: mkinstalldirs,  Prev: configure.in,  Up: Adjusting Files

`config.guess', `config.sub' at top level
-----------------------------------------

   If you haven't suppressed the `intl/' subdirectory, you need to add
the GNU `config.guess' and `config.sub' files to your distribution.
They are needed because the `intl/' directory has platform dependent
support for determining the locale's character encoding and therefore
needs to identify the platform.

   You can obtain the newest version of `config.guess' and `config.sub'
from `ftp://ftp.gnu.org/pub/gnu/config/'.  Less recent versions are
also contained in the GNU `automake' and GNU `libtool' packages.

   Normally, `config.guess' and `config.sub' are put at the top level
of a distribution.  But it is also possible to put them in a
subdirectory, altogether with other configuration support files like
`install-sh', `ltconfig', `ltmain.sh', `mkinstalldirs' or `missing'.
All you need to do, other than moving the files, is to add the
following line to your `configure.in'.

     AC_CONFIG_AUX_DIR([SUBDIR])


File: gettext.info,  Node: mkinstalldirs,  Next: aclocal,  Prev: config.guess,  Up: Adjusting Files

`mkinstalldirs' at top level
----------------------------

   If `gettextize' has not already done it, you need to add the GNU
`mkinstalldirs' script to your distribution.  It is needed because
`mkdir -p' is not portable enough.  You find this script in the GNU
`automake' distribution.

   Normally, `mkinstalldirs' is put at the top level of a distribution.
But it is also possible to put it in a subdirectory, altogether with
other configuration support files like `install-sh', `ltconfig',
`ltmain.sh' or `missing'.  All you need to do, other than moving the
files, is to add the following line to your `configure.in'.

     AC_CONFIG_AUX_DIR([SUBDIR])


File: gettext.info,  Node: aclocal,  Next: acconfig,  Prev: mkinstalldirs,  Up: Adjusting Files

`aclocal.m4' at top level
-------------------------

   If you do not have an `aclocal.m4' file in your distribution, the
simplest is to concatenate the files `codeset.m4', `gettext.m4',
`glibc21.m4', `iconv.m4', `intdiv0.m4', `inttypes.m4', `inttypes_h.m4',
`inttypes-pri.m4', `isc-posix.m4', `lcmessage.m4', `lib-ld.m4',
`lib-link.m4', `lib-prefix.m4', `progtest.m4', `stdint_h.m4',
`uintmax_t.m4', `ulonglong.m4' from GNU `gettext''s `m4/' directory
into a single file.  If you have suppressed the `intl/' directory, only
`gettext.m4', `iconv.m4', `lib-ld.m4', `lib-link.m4', `lib-prefix.m4',
`progtest.m4' need to be concatenated.

   If you already have an `aclocal.m4' file, then you will have to
merge the said macro files into your `aclocal.m4'.  Note that if you
are upgrading from a previous release of GNU `gettext', you should most
probably _replace_ the macros (`AM_GNU_GETTEXT', etc.), as they usually
change a little from one release of GNU `gettext' to the next.  Their
contents may vary as we get more experience with strange systems out
there.

   If you are using GNU `automake' 1.5 or newer, it is enough to put
these macro files into a subdirectory named `m4/' and add the line

     ACLOCAL_AMFLAGS = -I m4

to your top level `Makefile.am'.

   These macros check for the internationalization support functions
and related informations.  Hopefully, once stabilized, these macros
might be integrated in the standard Autoconf set, because this piece of
`m4' code will be the same for all projects using GNU `gettext'.


File: gettext.info,  Node: acconfig,  Next: config.h.in,  Prev: aclocal,  Up: Adjusting Files

`acconfig.h' at top level
-------------------------

   Earlier GNU `gettext' releases required to put definitions for
`ENABLE_NLS', `HAVE_GETTEXT' and `HAVE_LC_MESSAGES', `HAVE_STPCPY',
`PACKAGE' and `VERSION' into an `acconfig.h' file.  This is not needed
any more; you can remove them from your `acconfig.h' file unless your
package uses them independently from the `intl/' directory.


File: gettext.info,  Node: config.h.in,  Next: Makefile,  Prev: acconfig,  Up: Adjusting Files

`config.h.in' at top level
--------------------------

   The include file template that holds the C macros to be defined by
`configure' is usually called `config.h.in' and may be maintained
either manually or automatically.

   If it is maintained automatically, by use of the `autoheader'
program, you need to do nothing about it.  This is the case in
particular if you are using GNU `automake'.

   If it is maintained manually, and if `gettextize' has created an
`intl/' directory, you should switch to using `autoheader'.  The list
of C macros to be added for the sake of the `intl/' directory is just
too long to be maintained manually; it also changes between different
versions of GNU `gettext'.

   If it is maintained manually, and if on the other hand you have
suppressed the `intl/' directory by calling `gettextize' without
`--intl' option, then you can get away by adding the following lines to
`config.h.in':

     /* Define to 1 if translation of program messages to the user's
        native language is requested. */
     #undef ENABLE_NLS


File: gettext.info,  Node: Makefile,  Next: src/Makefile,  Prev: config.h.in,  Up: Adjusting Files

`Makefile.in' at top level
--------------------------

   Here are a few modifications you need to make to your main, top-level
`Makefile.in' file.

  1. Add the following lines near the beginning of your `Makefile.in',
     so the `dist:' goal will work properly (as explained further down):

          PACKAGE = @PACKAGE@
          VERSION = @VERSION@

  2. Add file `ABOUT-NLS' to the `DISTFILES' definition, so the file
     gets distributed.

  3. Wherever you process subdirectories in your `Makefile.in', be sure
     you also process the subdirectories `intl' and `po'.  Special
     rules in the `Makefiles' take care for the case where no
     internationalization is wanted.

     If you are using Makefiles, either generated by automake, or
     hand-written so they carefully follow the GNU coding standards,
     the effected goals for which the new subdirectories must be
     handled include `installdirs', `install', `uninstall', `clean',
     `distclean'.

     Here is an example of a canonical order of processing.  In this
     example, we also define `SUBDIRS' in `Makefile.in' for it to be
     further used in the `dist:' goal.

          SUBDIRS = doc intl lib src po

     Note that you must arrange for `make' to descend into the `intl'
     directory before descending into other directories containing code
     which make use of the `libintl.h' header file.  For this reason,
     here we mention `intl' before `lib' and `src'.

  4. A delicate point is the `dist:' goal, as both `intl/Makefile' and
     `po/Makefile' will later assume that the proper directory has been
     set up from the main `Makefile'.  Here is an example at what the
     `dist:' goal might look like:

          distdir = $(PACKAGE)-$(VERSION)
          dist: Makefile
          	rm -fr $(distdir)
          	mkdir $(distdir)
          	chmod 777 $(distdir)
          	for file in $(DISTFILES); do \
          	  ln $$file $(distdir) 2>/dev/null || cp -p $$file $(distdir); \
          	done
          	for subdir in $(SUBDIRS); do \
          	  mkdir $(distdir)/$$subdir || exit 1; \
          	  chmod 777 $(distdir)/$$subdir; \
          	  (cd $$subdir && $(MAKE) $@) || exit 1; \
          	done
          	tar chozf $(distdir).tar.gz $(distdir)
          	rm -fr $(distdir)


   Note that if you are using GNU `automake', `Makefile.in' is
automatically generated from `Makefile.am', and all needed changes to
`Makefile.am' are already made by running `gettextize'.


File: gettext.info,  Node: src/Makefile,  Next: lib/gettext.h,  Prev: Makefile,  Up: Adjusting Files

`Makefile.in' in `src/'
-----------------------

   Some of the modifications made in the main `Makefile.in' will also
be needed in the `Makefile.in' from your package sources, which we
assume here to be in the `src/' subdirectory.  Here are all the
modifications needed in `src/Makefile.in':

  1. In view of the `dist:' goal, you should have these lines near the
     beginning of `src/Makefile.in':

          PACKAGE = @PACKAGE@
          VERSION = @VERSION@

  2. If not done already, you should guarantee that `top_srcdir' gets
     defined.  This will serve for `cpp' include files.  Just add the
     line:

          top_srcdir = @top_srcdir@

  3. You might also want to define `subdir' as `src', later allowing
     for almost uniform `dist:' goals in all your `Makefile.in'.  At
     list, the `dist:' goal below assume that you used:

          subdir = src

  4. The `main' function of your program will normally call
     `bindtextdomain' (see *note Triggering::), like this:

          bindtextdomain (PACKAGE, LOCALEDIR);
          textdomain (PACKAGE);

     To make LOCALEDIR known to the program, add the following lines to
     Makefile.in:

          datadir = @datadir@
          localedir = $(datadir)/locale
          DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@

     Note that `@datadir@' defaults to `$(prefix)/share', thus
     `$(localedir)' defaults to `$(prefix)/share/locale'.

  5. You should ensure that the final linking will use `@LIBINTL@' or
     `@LTLIBINTL@' as a library.  `@LIBINTL@' is for use without
     `libtool', `@LTLIBINTL@' is for use with `libtool'. An easy way to
     achieve this is to manage that it gets into `LIBS', like this:

          LIBS = @LIBINTL@ @LIBS@

     In most packages internationalized with GNU `gettext', one will
     find a directory `lib/' in which a library containing some helper
     functions will be build.  (You need at least the few functions
     which the GNU `gettext' Library itself needs.)  However some of
     the functions in the `lib/' also give messages to the user which
     of course should be translated, too.  Taking care of this, the
     support library (say `libsupport.a') should be placed before
     `@LIBINTL@' and `@LIBS@' in the above example.  So one has to
     write this:

          LIBS = ../lib/libsupport.a @LIBINTL@ @LIBS@

  6. You should also ensure that directory `intl/' will be searched for
     C preprocessor include files in all circumstances.  So, you have to
     manage so both `-I../intl' and `-I$(top_srcdir)/intl' will be
     given to the C compiler.

  7. Your `dist:' goal has to conform with others.  Here is a
     reasonable definition for it:

          distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
          dist: Makefile $(DISTFILES)
          	for file in $(DISTFILES); do \
          	  ln $$file $(distdir) 2>/dev/null || cp -p $$file $(distdir); \
          	done



File: gettext.info,  Node: lib/gettext.h,  Prev: src/Makefile,  Up: Adjusting Files

`gettext.h' in `lib/'
---------------------

   Internationalization of packages, as provided by GNU `gettext', is
optional. It can be turned off in two situations:

   * When the installer has specified `./configure --disable-nls'. This
     can be useful when small binaries are more important than
     features, for example when building utilities for boot diskettes.
     It can also be useful in order to get some specific C compiler
     warnings about code quality with some older versions of GCC (older
     than 3.0).

   * When the package does not include the `intl/' subdirectory, and the
     libintl.h header (with its associated libintl library, if any) is
     not already installed on the system, it is preferrable that the
     package builds without internationalization support, rather than
     to give a compilation error.

   A C preprocessor macro can be used to detect these two cases.
Usually, when `libintl.h' was found and not explicitly disabled, the
`ENABLE_NLS' macro will be defined to 1 in the autoconf generated
configuration file (usually called `config.h'). In the two negative
situations, however, this macro will not be defined, thus it will
evaluate to 0 in C preprocessor expressions.

   `gettext.h' is a convenience header file for conditional use of
`<libintl.h>', depending on the `ENABLE_NLS' macro. If `ENABLE_NLS' is
set, it includes `<libintl.h>'; otherwise it defines no-op substitutes
for the libintl.h functions. We recommend the use of `"gettext.h"' over
direct use of `<libintl.h>', so that portability to older systems is
guaranteed and installers can turn off internationalization if they
want to. In the C code, you will then write

     #include "gettext.h"

instead of

     #include <libintl.h>

   The location of `gettext.h' is usually in a directory containing
auxiliary include files. In many GNU packages, there is a directory
`lib/' containing helper functions; `gettext.h' fits there.  In other
packages, it can go into the `src' directory.

   Do not install the `gettext.h' file in public locations. Every
package that needs it should contain a copy of it on its own.


File: gettext.info,  Node: autoconf macros,  Next: CVS Issues,  Prev: Adjusting Files,  Up: Maintainers

Autoconf macros for use in `configure.in'
=========================================

   GNU `gettext' installs macros for use in a package's `configure.in'
or `configure.ac'.  *Note Introduction: (autoconf)Top.  The primary
macro is, of course, `AM_GNU_GETTEXT'.

* Menu:

* AM_GNU_GETTEXT::              AM_GNU_GETTEXT in `gettext.m4'
* AM_GNU_GETTEXT_VERSION::      AM_GNU_GETTEXT_VERSION in `gettext.m4'
* AM_ICONV::                    AM_ICONV in `iconv.m4'


File: gettext.info,  Node: AM_GNU_GETTEXT,  Next: AM_GNU_GETTEXT_VERSION,  Prev: autoconf macros,  Up: autoconf macros

AM_GNU_GETTEXT in `gettext.m4'
------------------------------

   The `AM_GNU_GETTEXT' macro tests for the presence of the GNU gettext
function family in either the C library or a separate `libintl' library
(shared or static libraries are both supported) or in the package's
`intl/' directory.

   `AM_GNU_GETTEXT' accepts up to three optional arguments. The general
syntax is

     AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR])

   INTLSYMBOL can be one of `external', `no-libtool', `use-libtool'.
The default (if it is not specified or empty) is `no-libtool'.
INTLSYMBOL should be `external' for packages with no `intl/' directory,
and `no-libtool' or `use-libtool' for packages with an `intl/'
directory. If INTLSYMBOL is `use-libtool', then a libtool library
`$(top_builddir)/intl/libintl.la' will be created (shared and/or static,
depending on `--{enable,disable}-{shared,static}' and on the presence
of `AM_DISABLE_SHARED'). If INTLSYMBOL is `no-libtool', a static library
`$(top_builddir)/intl/libintl.a' will be created.

   If NEEDSYMBOL is specified and is `need-ngettext', then GNU gettext
implementations (in libc or libintl) without the `ngettext()' function
will be ignored.  If NEEDSYMBOL is specified and is
`need-formatstring-macros', then GNU gettext implementations that don't
support the ISO C 99 `<inttypes.h>' formatstring macros will be ignored.
Only one NEEDSYMBOL can be specified.  To specify more than one
requirement, just specify the strongest one among them.  The hierarchy
among the various alternatives is as follows: `need-formatstring-macros'
implies `need-ngettext'.

   INTLDIR is used to find the intl libraries.  If empty, the value
`$(top_builddir)/intl/' is used.

   The `AM_GNU_GETTEXT' macro determines whether GNU gettext is
available and should be used. If so, it sets the `USE_NLS' variable to
`yes'; it defines `ENABLE_NLS' to 1 in the autoconf generated
configuration file (usually called `config.h'); it sets the variables
`LIBINTL' and `LTLIBINTL' to the linker options for use in a Makefile
(`LIBINTL' for use without libtool, `LTLIBINTL' for use with libtool);
it adds an `-I' option to `CPPFLAGS' if necessary. In the negative
case, it sets `USE_NLS' to `no'; it sets `LIBINTL' and `LTLIBINTL' to
empty and doesn't change `CPPFLAGS'.

   The complexities that `AM_GNU_GETTEXT' deals with are the following:

   * Some operating systems have `gettext' in the C library, for example
     glibc. Some have it in a separate library `libintl'. GNU `libintl'
     might have been installed as part of the GNU `gettext' package.

   * GNU `libintl', if installed, is not necessarily already in the
     search path (`CPPFLAGS' for the include file search path,
     `LDFLAGS' for the library search path).

   * Except for glibc, the operating system's native `gettext' cannot
     exploit the GNU mo files, doesn't have the necessary locale
     dependency features, and cannot convert messages from the
     catalog's text encoding to the user's locale encoding.

   * GNU `libintl', if installed, is not necessarily already in the run
     time library search path. To avoid the need for setting an
     environment variable like `LD_LIBRARY_PATH', the macro adds the
     appropriate run time search path options to the `LIBINTL' and
     `LTLIBINTL' variables. This works on most systems, but not on some
     operating systems with limited shared library support, like SCO.

   * GNU `libintl' relies on POSIX `iconv'. The macro checks for linker
     options needed to use iconv and appends them to the `LIBINTL' and
     `LTLIBINTL' variables.


File: gettext.info,  Node: AM_GNU_GETTEXT_VERSION,  Next: AM_ICONV,  Prev: AM_GNU_GETTEXT,  Up: autoconf macros

AM_GNU_GETTEXT_VERSION in `gettext.m4'
--------------------------------------

   The `AM_GNU_GETTEXT_VERSION' macro declares the version number of
the GNU gettext infrastructure that is used by the package.

   The use of this macro is optional; only the `autopoint' program makes
use of it (*note CVS Issues::).


File: gettext.info,  Node: AM_ICONV,  Prev: AM_GNU_GETTEXT_VERSION,  Up: autoconf macros

AM_ICONV in `iconv.m4'
----------------------

   The `AM_ICONV' macro tests for the presence of the POSIX `iconv'
function family in either the C library or a separate `libiconv'
library. If found, it sets the `am_cv_func_iconv' variable to `yes'; it
defines `HAVE_ICONV' to 1 in the autoconf generated configuration file
(usually called `config.h'); it defines `ICONV_CONST' to `const' or to
empty, depending on whether the second argument of `iconv()' is of type
`const char **' or `char **'; it sets the variables `LIBICONV' and
`LTLIBICONV' to the linker options for use in a Makefile (`LIBICONV'
for use without libtool, `LTLIBICONV' for use with libtool); it adds an
`-I' option to `CPPFLAGS' if necessary. If not found, it sets
`LIBICONV' and `LTLIBICONV' to empty and doesn't change `CPPFLAGS'.

   The complexities that `AM_ICONV' deals with are the following:

   * Some operating systems have `iconv' in the C library, for example
     glibc. Some have it in a separate library `libiconv', for example
     OSF/1 or FreeBSD. Regardless of the operating system, GNU
     `libiconv' might have been installed. In that case, it should be
     used instead of the operating system's native `iconv'.

   * GNU `libiconv', if installed, is not necessarily already in the
     search path (`CPPFLAGS' for the include file search path,
     `LDFLAGS' for the library search path).

   * GNU `libiconv' is binary incompatible with some operating system's
     native `iconv', for example on FreeBSD.  Use of an `iconv.h' and
     `libiconv.so' that don't fit together would produce program
     crashes.

   * GNU `libiconv', if installed, is not necessarily already in the
     run time library search path. To avoid the need for setting an
     environment variable like `LD_LIBRARY_PATH', the macro adds the
     appropriate run time search path options to the `LIBICONV'
     variable. This works on most systems, but not on some operating
     systems with limited shared library support, like SCO.

   `iconv.m4' is distributed with the GNU gettext package because
`gettext.m4' relies on it.


File: gettext.info,  Node: CVS Issues,  Prev: autoconf macros,  Up: Maintainers

Integrating with CVS
====================

   Many projects use CVS for distributed development, version control
and source backup.  This section gives some advice how to manage the
uses of `cvs', `gettextize', `autopoint' and `autoconf'.

* Menu:

* Distributed CVS::             Avoiding version mismatch in distributed development
* Files under CVS::             Files to put under CVS version control
* autopoint Invocation::        Invoking the `autopoint' Program


File: gettext.info,  Node: Distributed CVS,  Next: Files under CVS,  Prev: CVS Issues,  Up: CVS Issues

Avoiding version mismatch in distributed development
----------------------------------------------------

   In a project development with multiple developers, using CVS, there
should be a single developer who occasionally - when there is desire to
upgrade to a new `gettext' version - runs `gettextize' and performs the
changes listed in *Note Adjusting Files::, and then commits his changes
to the CVS.

   It is highly recommended that all developers on a project use the
same version of GNU `gettext' in the package.  In other words, if a
developer runs `gettextize', he should go the whole way, make the
necessary remaining changes and commit his changes to the CVS.
Otherwise the following damages will likely occur:

   * Apparent version mismatch between developers.  Since some `gettext'
     specific portions in `configure.in', `configure.ac' and
     `Makefile.am', `Makefile.in' files depend on the `gettext'
     version, the use of infrastructure files belonging to different
     `gettext' versions can easily lead to build errors.

   * Hidden version mismatch.  Such version mismatch can also lead to
     malfunctioning of the package, that may be undiscovered by the
     developers.  The worst case of hidden version mismatch is that
     internationalization of the package doesn't work at all.

   * Release risks.  All developers implicitly perform constant testing
     on a package.  This is important in the days and weeks before a
     release.  If the guy who makes the release tar files uses a
     different version of GNU `gettext' than the other developers, the
     distribution will be less well tested than if all had been using
     the same `gettext' version.  For example, it is possible that a
     platform specific bug goes undiscovered due to this constellation.


File: gettext.info,  Node: Files under CVS,  Next: autopoint Invocation,  Prev: Distributed CVS,  Up: CVS Issues

Files to put under CVS version control
--------------------------------------

   There are basically three ways to deal with generated files in the
context of a CVS repository, such as `configure' generated from
`configure.in', `PARSER.c' generated from `PARSER.y', or
`po/Makefile.in.in' autoinstalled by `gettextize' or `autopoint'.

  1. All generated files are always committed into the repository.

  2. All generated files are committed into the repository occasionally,
     for example each time a release is made.

  3. Generated files are never committed into the repository.

   Each of these three approaches has different advantages and
drawbacks.

  1. The advantage is that anyone can check out the CVS at any moment
     and gets a working build.  The drawbacks are:  1a. It requires
     some frequent "cvs commit" actions by the maintainers.  1b. The
     reposity grows in size quite fast.

  2. The advantage is that anyone can check out the CVS, and the usual
     "./configure; make" will work.  The drawbacks are:  2a. The one who
     checks out the repository needs tools like GNU `automake', GNU
     `autoconf', GNU `m4' installed in his PATH; sometimes he even
     needs particular versions of them.  2b. When a release is made and
     a commit is made on the generated files, the other developers get
     conflicts on the generated files after doing "cvs update".
     Although these conflicts are easy to resolve, they are annoying.

  3. The advantage is less work for the maintainers.  The drawback is
     that anyone who checks out the CVS not only needs tools like GNU
     `automake', GNU `autoconf', GNU `m4' installed in his PATH, but
     also that he needs to perform a package specific pre-build step
     before being able to "./configure; make".

   For the first and second approach, all files modified or brought in
by the occasional `gettextize' invocation and update should be
committed into the CVS.

   For the third approach, the maintainer can omit from the CVS
repository all the files that `gettextize' mentions as "copy".
Instead, he adds to the `configure.in' or `configure.ac' a line of the
form

     AM_GNU_GETTEXT_VERSION(0.11.5)

and adds to the package's pre-build script an invocation of
`autopoint'.  For everyone who checks out the CVS, this `autopoint'
invocation will copy into the right place the `gettext' infrastructure
files that have been omitted from the CVS.


File: gettext.info,  Node: autopoint Invocation,  Prev: Files under CVS,  Up: CVS Issues

Invoking the `autopoint' Program
--------------------------------

     autopoint [OPTION]...

   The `autopoint' program copies standard gettext infrastructure files
into a source package.  It extracts from a macro call of the form
`AM_GNU_GETTEXT_VERSION(VERSION)', found in the package's
`configure.in' or `configure.ac' file, the gettext version used by the
package, and copies the infrastructure files belonging to this version
into the package.

Options
.......

`-f'
`--force'
     Force overwriting of files that already exist.

`-n'
`--dry-run'
     Print modifications but don't perform them.  All file copying
     actions that `autopoint' would normally execute are inhibited and
     instead only listed on standard output.

Informative output
..................

`--help'
     Display this help and exit.

`--version'
     Output version information and exit.

   `autopoint' supports the GNU `gettext' versions from 0.10.35 to the
current one, 0.11.5.  In order to apply `autopoint' to a package using
a `gettext' version newer than 0.11.5, you need to install this same
version of GNU `gettext' at least.

   In packages using GNU `automake', an invocation of `autopoint'
should be followed by invocations of `aclocal' and then `autoconf' and
`autoheader'.  The reason is that `autopoint' installs some autoconf
macro files, which are used by `aclocal' to create `aclocal.m4', and
the latter is used by `autoconf' to create the package's `configure'
script and by `autoheader' to create the package's `config.h.in'
include file template.

   The name `autopoint' is an abbreviation of `auto-po-intl-m4'; the
tool copies or updates mostly files in the `po', `intl', `m4'
directories.


File: gettext.info,  Node: Programming Languages,  Next: Conclusion,  Prev: Maintainers,  Up: Top

Other Programming Languages
***************************

   While the presentation of `gettext' focuses mostly on C and
implicitly applies to C++ as well, its scope is far broader than that:
Many programming languages, scripting languages and other textual data
like GUI resources or package descriptions can make use of the gettext
approach.

* Menu:

* Language Implementors::       The Language Implementor's View
* Programmers for other Languages::  The Programmer's View
* Translators for other Languages::  The Translator's View
* Maintainers for other Languages::  The Maintainer's View
* List of Programming Languages::  Individual Programming Languages
* List of Data Formats::        Internationalizable Data


File: gettext.info,  Node: Language Implementors,  Next: Programmers for other Languages,  Prev: Programming Languages,  Up: Programming Languages

The Language Implementor's View
===============================

   All programming and scripting languages that have the notion of
strings are eligible to supporting `gettext'.  Supporting `gettext'
means the following:

  1. You should add to the language a syntax for translatable strings.
     In principle, a function call of `gettext' would do, but a
     shorthand syntax helps keeping the legibility of internationalized
     programs.  For example, in C we use the syntax `_("string")', in
     bash we use the syntax `$"string"', and in GNU awk we use the
     shorthand `_"string"'.

  2. You should arrange that evaluation of such a translatable string at
     runtime calls the `gettext' function, or performs equivalent
     processing.

  3. Similarly, you should make the functions `ngettext', `dcgettext',
     `dcngettext' available from within the language.  These functions
     are less often used, but are nevertheless necessary for particular
     purposes: `ngettext' for correct plural handling, and `dcgettext'
     and `dcngettext' for obeying other locale environment variables
     than `LC_MESSAGES', such as `LC_TIME' or `LC_MONETARY'.  For these
     latter functions, you need to make the `LC_*' constants, available
     in the C header `<locale.h>', referenceable from within the
     language, usually either as enumeration values or as strings.

  4. You should allow the programmer to designate a message domain,
     either by making the `textdomain' function available from within
     the language, or by introducing a magic variable called
     `TEXTDOMAIN'.  Similarly, you should allow the programmer to
     designate where to search for message catalogs, by providing
     access to the `bindtextdomain' function.

  5. You should either perform a `setlocale (LC_ALL, "")' call during
     the startup of your language runtime, or allow the programmer to
     do so.  Remember that gettext will act as a no-op if the
     `LC_MESSAGES' and `LC_CTYPE' locale facets are not both set.

  6. A programmer should have a way to extract translatable strings
     from a program into a PO file.  The GNU `xgettext' program is being
     extended to support very different programming languages.  Please
     contact the GNU `gettext' maintainers to help them doing this.  If
     the string extractor is best integrated into your language's
     parser, GNU `xgettext' can function as a front end to your string
     extractor.

  7. The language's library should have a string formatting facility
     where the arguments of a format string are denoted by a positional
     number or a name.  This is needed because for some languages and
     some messages with more than one substitutable argument, the
     translation will need to output the substituted arguments in
     different order.  *Note c-format Flag::.

  8. If the language has more than one implementation, and not all of
     the implementations use `gettext', but the programs should be
     portable across implementations, you should provide a no-i18n
     emulation, that makes the other implementations accept programs
     written for yours, without actually translating the strings.

  9. To help the programmer in the task of marking translatable strings,
     which is usually performed using the Emacs PO mode, you are
     welcome to contact the GNU `gettext' maintainers, so they can add
     support for your language to `po-mode.el'.

   On the implementation side, three approaches are possible, with
different effects on portability and copyright:

   * You may integrate the GNU `gettext''s `intl/' directory in your
     package, as described in *Note Maintainers::.  This allows you to
     have internationalization on all kinds of platforms.  Note that
     when you then distribute your package, it legally falls under the
     GNU General Public License, and the GNU project will be glad about
     your contribution to the Free Software pool.

   * You may link against GNU `gettext' functions if they are found in
     the C library.  For example, an autoconf test for `gettext()' and
     `ngettext()' will detect this situation.  For the moment, this test
     will succeed on GNU systems and not on other platforms.  No severe
     copyright restrictions apply.

   * You may emulate or reimplement the GNU `gettext' functionality.
     This has the advantage of full portability and no copyright
     restrictions, but also the drawback that you have to reimplement
     the GNU `gettext' features (such as the `LANGUAGE' environment
     variable, the locale aliases database, the automatic charset
     conversion, and plural handling).


File: gettext.info,  Node: Programmers for other Languages,  Next: Translators for other Languages,  Prev: Language Implementors,  Up: Programming Languages

The Programmer's View
=====================

   For the programmer, the general procedure is the same as for the C
language.  The Emacs PO mode supports other languages, and the GNU
`xgettext' string extractor recognizes other languages based on the
file extension or a command-line option.  In some languages,
`setlocale' is not needed because it is already performed by the
underlying language runtime.


File: gettext.info,  Node: Translators for other Languages,  Next: Maintainers for other Languages,  Prev: Programmers for other Languages,  Up: Programming Languages

The Translator's View
=====================

   The translator works exactly as in the C language case.  The only
difference is that when translating format strings, she has to be aware
of the language's particular syntax for positional arguments in format
strings.

* Menu:

* c-format::                    C Format Strings
* python-format::               Python Format Strings
* lisp-format::                 Lisp Format Strings
* elisp-format::                Emacs Lisp Format Strings
* librep-format::               librep Format Strings
* smalltalk-format::            Smalltalk Format Strings
* java-format::                 Java Format Strings
* awk-format::                  awk Format Strings
* object-pascal-format::        Object Pascal Format Strings
* ycp-format::                  YCP Format Strings
* tcl-format::                  Tcl Format Strings


File: gettext.info,  Node: c-format,  Next: python-format,  Prev: Translators for other Languages,  Up: Translators for other Languages

C Format Strings
----------------

   C format strings are described in POSIX (IEEE P1003.1 2001), section
XSH 3 fprintf(),
`http://www.opengroup.org/onlinepubs/007904975/functions/fprintf.html'.
See also the fprintf(3) manual page,
`http://www.linuxvalley.it/encyclopedia/ldp/manpage/man3/printf.3.php',
`http://informatik.fh-wuerzburg.de/student/i510/man/printf.html'.


File: gettext.info,  Node: python-format,  Next: lisp-format,  Prev: c-format,  Up: Translators for other Languages

Python Format Strings
---------------------

   Python format strings are described in Python Library reference /
2. Built-in Types, Exceptions and Functions / 2.2. Built-in Types /
2.2.6. Sequence Types / 2.2.6.2. String Formatting Operations.
`http://www.python.org/doc/2.2.1/lib/typesseq-strings.html'.


File: gettext.info,  Node: lisp-format,  Next: elisp-format,  Prev: python-format,  Up: Translators for other Languages

Lisp Format Strings
-------------------

   Lisp format strings are described in the Common Lisp HyperSpec,
chapter 22.3 Formatted Output,
`http://www.lisp.org/HyperSpec/Body/sec_22-3.html'.


File: gettext.info,  Node: elisp-format,  Next: librep-format,  Prev: lisp-format,  Up: Translators for other Languages

Emacs Lisp Format Strings
-------------------------

   Emacs Lisp format strings are documented in the Emacs Lisp reference,
section Formatting Strings,
`http://www.gnu.org/manual/elisp-manual-21-2.8/html_chapter/elisp_4.html#SEC75'.
Note that as of version 21, XEmacs supports numbered argument
specifications in format strings while FSF Emacs doesn't.

