[GRASS-translations] Translation of messages and errors in Scripts

Glynn Clements glynn at gclements.plus.com
Thu May 19 01:04:58 EDT 2011


Monica Buescu wrote:

> I was able to translate all messages from Scripts and Modules interfaces
> (description; keys,...) but Now I want to translate the messages that I
> print. (using g.message, grass.message, grass.fatal) but it seems that it's
> not poissible. Can anyone confirm me ? because I have been searching for
> (example i.tasscap) printed messages and none is translated only thte
> interfaces. Can anyone just give me a clue on this?

[The following applies to 7.0; 6.x still uses shell scripts, which
aren't particularly amenable to I18N.]

Currently, scripts aren't scanned for translatable messages when
generating the .pot files, so you would need to update the
grasslibs.pot file manually (the Python scripting library uses the
"grasslibs" domain for _(), not "grassmods").

The lack of scanning shouldn't be hard to fix. The Python files in
lib/python are already scanned. See locale/Makefile.

The grasslibs/grassmods issue is more problematic. gettext.install()
adds the _() function to Python's builtins namespace, so that it is
available in all modules without having to explicitly import it in
each file.

This means that the grass.script modules use the same translation
domain as the script itself, so either both must use grasslibs or both
must use grassmods. Unlike in C, where _() is a macro and the domain
depends upon the source file.

Solutions include:

1. Leave it as it is.

2. Change the gettext.install() to use grassmods (or e.g. 
grassscripts), which will affect both the script and the library.

3. Define a _() function which uses grassmods, and have the scripts
use "from grass.script import _".

4. Change the gettext.install() call to use grassmods, define a _()
function which uses grasslibs, and have the library use
"from grass.script import _".

BTW, I note that some of the wxGUI modules import grass.script,
although wxGUI also calls gettext.install() for with grasswxpy as the
domain. I don't know whether anyone has actually thought this through.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-translations mailing list