[GRASS-dev] Using non-ASCII characters in Grass.message and grass.fatal

Glynn Clements glynn at gclements.plus.com
Tue Jul 26 19:30:33 EDT 2011


António Rocha wrote:

> I would like to know if is there any way to use non-ASCII characters 
> (e.g. à; ã; â; á, é) in grass.message and grass.fatal Python modules?

The code won't care; with few exceptions, the GRASS libraries and
modules treat strings as sequences of bytes, not characters.

However, if you want the script to work correctly with different
locales, you'll need to explicitly convert to the locale's encoding,
and handle the case where such conversions aren't possible (e.g. if
the user's locale uses ASCII).

> By the way, just to confirm this, it's not possible to sue *.po files to 
> translate messages and strings in grass.message and grass.fatal (Python 
> Scripts) right?

g.message doesn't translate the message. This would be problematic for
messages which aren't fixed (see my recent reply re: "g.manual
expression missing").

In Python scripts, you can use _(...) (a function whose name is a
single underscore), but there isn't a convenient solution for shell
scripts.

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


More information about the grass-dev mailing list