wxpython and wxlocale

Y

Ya

Problem:
In a computer it is wanted to install an application that must show
information in different languages.
Thanks to the module we, gettext, have been able to implement that the texts
that are shown are translated.
The user selects the language and act from a file .mo every language.
The problem are the messages and dialogues since it shows the buttons in the
language of the operating system by default.
Is there any way of telling python that the text of the dialogues is in a
specific language?
And in affirmative case. How is it made? since all the attempts have been
useless.
I think that wxLocale has to be used, but I do not become clear.

We are using Python 2.3.3 and wxpython 2.4.2.4 in W2K.

Greetings.
 
J

Jarek Zgoda

Ya said:
Is there any way of telling python that the text of the dialogues is in a
specific language?
And in affirmative case. How is it made? since all the attempts have been
useless.
I think that wxLocale has to be used, but I do not become clear.

loc = wx.Locale()
loc.Init(wx.LANGUAGE_POLISH)

Et voila, your program uses Polish dialogs.
 
Y

Ya

This is my code:
The button of "OK" is not translated.
What is wrong ?

#I have a mo file named myapp.mo for translate my own dialogs.
#its containt
#....
#....
#: myapp.py:23
#msgid "Hello World"
#msgstr "Bonjour Monde"
#...
#in this location .\locale\fr\LC_MESSAGES

import gettext
from wxPython.wx import *
import wx
import locale
import sys, os, time

def startapp(self):

self.loc = wx.Locale()
self.loc.Init(wx.LANGUAGE_FRENCH)

gettext.translation("myapp", ".\locale",languages=['fr']).install()

#display then message "Bonjour Monde", but the OK button not is
translate!!!!!
dlg = wxMessageDialog(None, _('Hello World'),'', wxOK |
wxICON_INFORMATION)
try:
dlg.ShowModal()
finally:
dlg.Destroy()

class BoaApp(wxApp):
def OnInit(self):
wxInitAllImageHandlers()
startapp(self)
return True

def main():
try:
demopath= os.path.dirname(__file__)
os.chdir(demopath)
except:
pass
application = BoaApp(0)
application.MainLoop()

if __name__ == '__main__':
main()
 
D

David Bolen

Ya said:
This is my code:
The button of "OK" is not translated.
What is wrong ?

I believe this was discussed recently on the wxPython list. Under
Windows, wxMessageDialog creates a native Windows dialog, so
wxPython/wxWindows is not in control of the basic dialog buttons (such
as OK). They are therefore under control of the OS as far as
internationalization goes, and will only obey the system settings.

So if you need to operate in a localized setting other than that of
the host operating system, I'm guessing you're best bet is to make
your own dialog box rather than using wxMessageDialog.

To add to the complexity (if I recall correctly), wxMessageDialog is
implemented by wxWindows itself under Linux/GTK, so you don't see the
same problem there. Clearly not an ideal situation, but one of the
wrinkles that comes from trying to use native widgets on a platform
when available.

The wxPython list is probably a better place to get further details.

-- David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,665
Latest member
salkete

Latest Threads

Top