GRASS code internationalization  (i18n) mini-HOWTO.
                            by Alex Shevlakov sixote@yahoo.com
 
1. GRASS modules code and Gmakefile changes.
2. GRASS libraries code and Gmakefile changes.
3. Using gettext binaries for messages catalogues creation and maintenance.


1. GRASS modules code and Gmakefile changes.

To prepare a module being able to translate its messages to the user's locale national language, the module's developer or maintainer has to make the following changes into the code and Gmakefile of this module:
 

a) Lines of C code which contain translatable strings, e.g.,
  fprintf(stderr, "This module is cool!\n");
have to be replaced with
  fprintf(stderr, _("This module is cool!\n"));
i.e., all "comments" are put inside brackets and underscored from the left, thus becoming _("comments"). No changes into any other lines are needed.

b) Files with C code that have been modified in this way must be referenced to the header file "glocale.h". Add line #include "glocale.h" somewhere below other 'include' directives.

c) The Gmakefile of this module has to be modified to have the following additional compiler options definitions in it:

PACKAGE = "your_module_name"
DEFS = -DPACKAGE=\"$(PACKAGE)\"
EXTRA_CFLAGS    = $(...) $(...) ... $(DEFS)


2. GRASS libraries code and Gmakefile changes.

Statements a), b) and c) from the first paragraph wholly apply to the procedure of GRASS libraries code i18n changes.  The 'PACKAGE' variable would be called, for libraries, 'libgis' or 'libraster', etc.

3. Using gettext binaries for messages catalogues creation and maintenance.
 

In the C files catalogue of a module or library, run command:

   xgettext -a *.c -o your_module_name.po

This creates a new template .po file which you (module NLS maintainer) have to edit. See other manuals and HOWTO's that explicitly cover the .po files editing, including header part with names of the translation team members. Usually, it is just enough to take any existing .po file as ready example.

After your .po file is ready, test that the module and libs translate new messages: run

   msgfmt your_module_name.po -o your_module_name.mo

and put the result .mo file in the GRASS locale catalogue ($GISBASE/locale/your_language/LC_MESSAGES). Then run the module and see if the translations are done correctly.

From time to time, as the code gets changed by developers, run

   msgmerge old.po new.po > your_module_name.po

where old.po is the outdated version of the module and new.po is done by 'xgettext -a *.c'. This updates translatable line numbers.