is wxTextEntryDialog() text affected by wxLocale() and/or locale .setlocale?

Is there an easy way to merge wxstd.mo to my own catalog. I used

pygettext.py

and msgfmt.py to create my own catalog. I tried to install both catalog at

my

program run time but that does not seem to work:

       gettext.install('ivcm', './manual', unicode=0)
       gettext.install('wxstd', './manual', unicode=0)

There isn't any integration between the Python gettext and the one used in

wxWindows. You can use either from Python, but the wxWindows C++ code can only
use the gettext tools it was compiled with. This means that you probably need
to do something like this:

    wxLocale_AddCatalogLookupPathPrefix('./manual')
    # this will load wxstd automatically
    self.locale = wxLocale(wxLANGUAGE_DEFAULT)

Then the wxWindows code should find all its text items in the default

catalog. You should also be able to use wxLocale for your own catalogs from
Python code, just do something like this to load the message catalog and to
rebind the '_' function:

   self.locale.AddCatalog('ivcm')
   _ = wxGetTranslation

Thanks for the tip!

Just placing wxLocale_AddCatalogLookupPathPrefix('./manual') in the code did the
work.

So, i am using the Python standard gettext and wx the following way and it works
fine:

to start:
     from wxPython.wx import *
     import gettext
     ....
     if not os.environ.has_key('LANGUAGE'):
          os.environ['LANGUAGE'] = 'en'
     if os.environ['LANGUAGE'] not in ["en", "fr"]:
          os.environ['LANGUAGE'] = 'en'
     gettext.install('ivcm', './manual', unicode=0)
     wxLocale_AddCatalogLookupPathPrefix('./manual')

In my application class __init__:

     self.presLang = os.environ['LANGUAGE'] # Select current langauge
     self.presLan_en = gettext.translation("ivcm", "./manual", languages=['en'])
     self.presLan_fr = gettext.translation("ivcm", "./manual", languages=['fr'])

# To dynamically switch to French:

     def OnMnuEnglish(self, event):
        self.presLang = "en"
        self.presLan_en.install()
        self.locale = wxLocale(wxLANGUAGE_ENGLISH)
        locale.setlocale(locale.LC_ALL, self.presLang)
        self.resetAllText()
        # all processing done.

#To dynamically switch back to English:

    def OnMnuFrench(self, event):
        self.presLang = "fr"
        self.presLan_fr.install()
        self.locale = wxLocale(wxLANGUAGE_FRENCH)
        locale.setlocale(locale.LC_ALL, self.presLang)
        self.resetAllText()
        # all processing done.

Notice that i do not define a _() function in my code. Using gettext.install()
seems to do it for me.
I tested the code by disabling the WxPython wxstd.mo in the fr locale directory
(renamed the file) .

What is the difference between wxPython support of gettext and Python 'native'
gettext. Why should we use wxPython one?

Also note that my wxPython program can be stared from the command line
and it has a printUsage() function that displays information if the command line
is wrong. Using gettext allows me to translate the console messages as well.
So both the console output, the switches, and the GUI is translated.

Thanks for your help!

···

--
Pierre Rouleau

Pierre_Rouleau@ImpathNetworks.com wrote:

Notice that i do not define a _() function in my code. Using gettext.install()
seems to do it for me.

Yeah, I think it dynamically adds it to the builtins module.

What is the difference between wxPython support of gettext and Python 'native'
gettext. Why should we use wxPython one?

There is probably no real difference, they are based on the same principles and standards underneath. The only reason I suggest using the one in wxPython is to reduce runtime resources a bit and to narrow down the number of places that have to be checked in case there is a problem.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!