Next: , Up: Parser Internationalization   [Contents][Index]

4.6.1 Enabling Internationalization

The maintainer of a package that uses a Bison-generated parser enables the internationalization of the parser’s output through the following steps. Here we assume a package that uses GNU Autoconf and GNU Automake.

  1. Into the directory containing the GNU Autoconf macros used by the package —often called m4— copy the bison-i18n.m4 file installed by Bison under ‘share/aclocal/bison-i18n.m4’ in Bison’s installation directory. For example:
    cp /usr/local/share/aclocal/bison-i18n.m4 m4/bison-i18n.m4
  2. In the top-level, after the AM_GNU_GETTEXT invocation, add an invocation of BISON_I18N. This macro is defined in the file bison-i18n.m4 that you copied earlier. It causes configure to find the value of the BISON_LOCALEDIR variable, and it defines the source-language symbol YYENABLE_NLS to enable translations in the Bison-generated parser.
  3. In the main function of your program, designate the directory containing Bison’s runtime message catalog, through a call to ‘bindtextdomain’ with domain name ‘bison-runtime’. For example:
    bindtextdomain ("bison-runtime", BISON_LOCALEDIR);

    Typically this appears after any other call bindtextdomain (PACKAGE, LOCALEDIR) that your package already has. Here we rely on ‘BISON_LOCALEDIR’ to be defined as a string through the Makefile.

  4. In the that controls the compilation of the main function, make ‘BISON_LOCALEDIR’ available as a C preprocessor macro, either in ‘DEFS’ or in ‘AM_CPPFLAGS’. For example:


  5. Finally, invoke the command autoreconf to generate the build infrastructure.