how to make wxPython translate msgs from XRC file?

how to make wxPython translate messages from XRC file which are already translated at MO file (but without any refs, like: #: ../file.py:150)!? All messages ( _ ("some msg") ) from *.py files translated good!

···

--
WBR, sector119

It does not want to translate <title>Phone Book</title>
Why?

#!/usr/bin/env python

import os, sys
import gettext

message_dir = os.path.join(sys.path[0], "locale")
gettext.textdomain("pbook")
gettext.bindtextdomain("pbook", message_dir)
_ = gettext.gettext

try:
   from wxPython.wx import *
   from wxPython.xrc import *
except:
   sys.exit(_("Error: *** wxPython module not found ***"))

class App(wxApp):
   def OnInit(self):
     self.res = wxXmlResource("pbook.xrc", wxXRC_USE_LOCALE)
     self.InitFrame()
     self.frame.Show(True)
     self.SetTopWindow(self.frame)
     self.keepGoing = True
     return True

   def InitFrame(self):
     self.frame = self.res.LoadFrame(None, "MainFrame")

def main():
   app = App()
   app.MainLoop()

if __name__ == "__main__":
   main()

<?xml version="1.0" encoding="UTF-8"?>
<resource>
   <object class="wxFrame" name="MainFrame">
     <style>wxDEFAULT_FRAME_STYLE</style>
     <size>200, 100</size>
     <title>Phone Book</title>
   </object>
</resource>

Robin Dunn wrote:

···

If you construct the wxXmlResource using the wxXRC_USE_LOCALE flag (which it does by default) then wxXmlResource will use wxLocale (via wxGetTranslation I think) to read strings from the loaded message catalogs.

--
WBR, sector119

Sergei Levchenko wrote:

It does not want to translate <title>Phone Book</title>
Why?

You need to use wxLocale. XRC only knows about wx i18n functionality, it has no way of using Python's gettext. You can either do everything via wxLocal (set _ to wxGetTranslation) or you can use both if you want, but the strings compiled in wxWidets and those loaded from XRC can only be translated using wxLocale.

See also: http://wiki.wxpython.org/index.cgi/Internationalization

···

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