how to localize a common dialog box

Hi list,

does anybody know how to display a common dialog box such as
wxDirDialog with its strings translated to the language used by the
code calling this dialog box (in this case, German)? I could translate
the message given as parameter to wxDirDialog constructor. Also, the
title could be easily changed by using wxDialog::SetTitle(), but the
name of the buttons, how could I also translate them?...

Thanks,

Cristina.

You need to activate the locale system.

"import locale" and wx.Locale are your friend.

Karsten

···

On Thu, Jul 10, 2008 at 02:45:57PM +0300, Public cai wrote:

does anybody know how to display a common dialog box such as
wxDirDialog with its strings translated to the language used by the
code calling this dialog box (in this case, German)? I could translate
the message given as parameter to wxDirDialog constructor. Also, the
title could be easily changed by using wxDialog::SetTitle(), but the
name of the buttons, how could I also translate them?...

--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

Note that you can use gettext and local or wx.GetTranslation and
wx.Locale, you should use the later if you want wxPython standard
strings to be translated

Note that this is NOT a requirement for wxPython-internal
strings (such as stock button labels) to be translated. BOTH
ways work. All one needs to make sure is that the normal
Python library locale/gettext modules are imported and
initialized *before* wxPython is imported. But that would be
Good Practice anyway.

The reason being that, apparently, during its startup
wxPython detects the currently activated system locale and
adjusts itself to that. So, if the Python library module
locale.setlocale(locale.LC_ALL) was called appropriately,
wxPython will automatically be in the right locale, too.
This is perfectly sane from a software engineering point of
view as wxPython is a layer on top of Python (and other
things) so as long as Python did the right thing early
enough wxPython should, too (and it does).

and when you distribute your application you
should not forget to include the appropriate language.mo files from the
wxPython version you are using.

That advice is prudent but only applies on Windows. On Linux
and/or Mac make sure to have the package manager install any
needed i18n dependancy packages.

Karsten

···

On Thu, Jul 10, 2008 at 02:42:41PM +0200, Werner F. Bruhin wrote:
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

Thanks for putting me right,

You were not entirely wrong either :wink:

Just wanted to clarify a bit more.

I wasn't aware of the fact that the order
was enough to get wxPython play nicely with locale/gettext.

At least that's what I observe with GNUmed on
Linux/Windows/MacOSX.

Karsten

···

On Thu, Jul 10, 2008 at 03:35:02PM +0200, Werner F. Bruhin wrote:
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346