469,364 Members | 2,346 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,364 developers. It's quick & easy.

wxpython and wxlocale

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.

Jul 18 '05 #1
4 2986
Ya <tm*******@ammsoft.com> pisze:
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.

--
Jarek Zgoda
Unregistered Linux User #-1
http://www.zgoda.biz/ JID:zgoda-a-chrome.pl http://zgoda.jogger.pl/
Jul 18 '05 #2
Jarek Zgoda wrote:
Ya <tm*******@ammsoft.com> pisze:

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.

And if you want to internationalize your OWN dialogs:

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

Brian

Jul 18 '05 #3
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()

"Jarek Zgoda" <jz****@gazeta.usun.pl> escribió en el mensaje
news:bv**********@atlantis.news.tpi.pl...
Ya <tm*******@ammsoft.com> pisze:
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.

--
Jarek Zgoda
Unregistered Linux User #-1
http://www.zgoda.biz/ JID:zgoda-a-chrome.pl http://zgoda.jogger.pl/

Jul 18 '05 #4
"Ya" <tm*******@ammsoft.com> writes:
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
Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Logan | last post: by
7 posts views Thread by SeeBelow | last post: by
25 posts views Thread by BJörn Lindqvist | last post: by
1 post views Thread by timothy.williams | last post: by
1 post views Thread by James Stroud | last post: by
reply views Thread by Robin Dunn | last post: by
reply views Thread by Robin Dunn | last post: by
4 posts views Thread by stef | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.