[GRASS5] i18n GRASS mechanism description

Hi,

seems like we are ready to begin writing strings for
GRASS i18n.

To facilitate the task for those who could possibly join
this:

All I have about methods doing this work is in Russian (unfortunately).
http://www.cs.msiu.ru/projects/kurs/1999/oop/Antipov/HTML/node24.html

Here's a link to the gnu site with explanations I could not use
because I'm not Emacs user.
http://www.gnu.org/manual/gettext/html_chapter/gettext_toc.html

a brief way to create .po and .mo filez:

[user@host:somedir] xgettext -a *.c -o some_module.po

This makes a template which must be edited. Unneeded fields are removed,
those that correspond to translatable strings are translated. Don't
forget editing the header with encoding entries.

[user@host:somedir] msgfmt some_module.po -o some_module.mo

This makes the machine file (.mo). Both files would go to grass/locale/your_locale/LC_MESSAGES. That's where the prog will look for them.
If you don't put the .mo file to this directory, you'll see the
program output strings unchanged. (as if only English was there).

Now you'ready to begin changing strings
in progs to test your localization (unless someone has done it for you,
I have submitted so far g.select.pg and g.table.pg):

Add the following two line to Gmakefile:

PACKAGE = "your.module"
DEFS = -Wall -DPACKAGE=\"$(PACKAGE)\"

Add #include "glocale.h"

to all c-files with strings (corresponding to the .po files you just edited).

Add the 5 lines to main.c:

#ifdef HAVE_LIBINTL_H
  setlocale (LC_MESSAGES, "");
  bindtextdomain (PACKAGE, LOCALEDIR);
  textdomain (PACKAGE);
#endif

Now, change all the translatable strings like this:
list->description = _("Use -l flag for list of databases.");

OR

if(list->answer) {
        printf(_("The following databases are in the Unix catalogue:\n"));

I.e., you should change the "stringstringstring" to _("stringstringstring")

wherever you want it be translated.

Seems like this is it.

Glynn, I think of the mechanism you mentioned as basis for locale maintainers,
and it is easy to search for diffs between the templates you created last time
and now.

--alex

Alex Shevlakov wrote:

a brief way to create .po and .mo filez:

[user@host:somedir] xgettext -a *.c -o some_module.po

This makes a template which must be edited. Unneeded fields are removed,
those that correspond to translatable strings are translated. Don't
forget editing the header with encoding entries.

[user@host:somedir] msgfmt some_module.po -o some_module.mo

This makes the machine file (.mo). Both files would go to
grass/locale/your_locale/LC_MESSAGES. That's where the prog will
look for them.

A couple of notes:

1. The .po files should be committed to CVS, and the .mo files should
be constructed during the build process. It would help to have a
standard format for the make rules, so that gmake5 etc can process
them if necessary.

2. Don't blindly localise every string literal. Anything which might
be read by a program (including users' scripts) should probably remain
untranslated.

Glynn, I think of the mechanism you mentioned as basis for locale maintainers,
and it is easy to search for diffs between the templates you created last time
and now.

So locale maintainers will "poll" the source code for changes? That
certainly keeps things simple for the developers.

--
Glynn Clements <glynn.clements@virgin.net>