[wxPython-users] wx.Locale mystery
Cody Precord
codyprecord at gmail.com
Thu Dec 20 03:27:15 PST 2007
Hello,
I do something like the following,
import gettext
import wx
the_locale = wx.Locale(wx.LANGUAGE_***)
the_locale.AddCatalogLookupPathPrefix("path/to/gettext mo files/")
the_locale.AddCatalog("PROGRAM NAME") # Assuming locale files are
named PROGRAM NAME.mo
language = gettext.translation("PROGRAM NAME", "path/to/locale files
dir/",
["Canonical
Name (i.e. sv_SE)"],
fallback=True)
language.install()
Also be sure that the wxLocale object remains alive during the
runtime of your program.
Regards,
Cody Precord
On Dec 20, 2007, at 5:12 AM, Donn Ingle wrote:
> Hi again,
> I'm going slightly mad. Here's the setup:
>
> 1. I have a .mo file in the right place and I know it works because
> the
> normal Python gettext procedure is working.
> 2. I have installed the Swedish locale (don't ask me why :) ) and I
> know it
> works because of 1. (I also test with af_ZA.utf8)
> 3. Before I run the app I set [LANG=sv_SE.utf8]
>
> * I'm on Kubuntu Gnu/Linux, Python 2.5, wxPython 2.8 unicode.
>
> I am doing this (from the wiki):
>
> langid = wx.LANGUAGE_DEFAULT # Assume it fetches from $LANG
> localedir = "fontypython/locales"
> langid = wx.LANGUAGE_SWEDISH # trying to force it
> os.environ['LANG'] = "sv_SE.utf8" # force it again!
> mylocale = wx.Locale( langid )
> mylocale.AddCatalogLookupPathPrefix( localedir )
> mylocale.AddCatalog( "wxgui" ) # it finds this file.
> _ = wx.GetTranslation
>
> # All these show that it has Swedish
> print mylocale.GetCanonicalName()
> print mylocale.GetLanguage()
> print mylocale.GetLocale()
> print mylocale.GetName()
> # But this one will not work... :(
> print wx.GetTranslation("Some String")
> print _("Some String") # Does not work either.
>
> Also, to test things out, I run the wxPython demo under another
> LANG setting
> and it does not seem to change. I'm pretty sure I have at least
> af_ZA.utf8
> installed fully (Swedish may be broken). I was looking at the stock
> buttons
> control, to see if the text labels would change language but they
> steadfastly remain in English.
>
> I am using a few stock buttons in the app and was relying on them
> 'just
> working'.
>
> I am sure I'm to blame, but it's such a minefield that I'm just lost.
>
> Is there another module of wxPython I still need to install?
> \d
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-
> help at lists.wxwidgets.org
>
More information about the wxpython-users
mailing list