[GRASS-dev] Some string not translated in wxGUI

Glynn Clements glynn at gclements.plus.com
Wed Feb 17 14:10:30 EST 2010


Markus Neteler wrote:

> >> some messages (see below/screenshot) are not shown in translation. They are
> >> coming from grasslibs_XX.po and are translated in JA and DE but still appear
> >> in English. Somehow the translations are not propagated to the wxGUI.
> >
> > In 6.x, those strings aren't localised in G_usage_xml(). Try r41031
> > (for 6.5).
> 
> This helps, backported.
> 
> Yet another one is there (DE example):
> 
> #: ../gui/wxpython/gui_modules/menuform.py:871
> #: ../gui/wxpython/gui_modules/preferences.py:1131
> msgid "Close dialog on finish"
> msgstr "Schließe den Dialog beim Beenden"
> 
> But they are indicated correctly:
> [neteler at north grass64]$ grep 'Close dialog on f' gui/*/*/*
> gui/wxpython/gui_modules/menuform.py:
>       label=_('Close dialog on finish'), style = wx.NO_BORDER)
> gui/wxpython/gui_modules/preferences.py:
> label=_("Close dialog on finish"),
> 
> To get things like
>    'label=_("Close dialog on finish")'
> shown translated in the file preferences.py, I had to add the "import gettext"
> stuff (yet unsubmitted).
> 
> Looking around I found other .py files lacking the gettext stuff.
> What's the right way to do it? Add everywhere or is there a better way?
> Or can it be inherited from globalvar.py or another file?

For any process, the __main__ module (the one which is executed rather
than "import"ed) should call gettext.install. This inserts the "_"
function into the global namespace.

The call in wxgui.py should be sufficient for the GUI itself, but
menuform.py also requires it for the case where it is executed from
G_gui().

IOW, any module which uses:

	if __name__ == '__main__':
	    ....

(other than for debug/test/demonstration purposes) should call
gettext.install within that section of code (calling it from the top
level is suboptimal, but probably harmless).

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


More information about the grass-dev mailing list