Thanks Dieter! Just tested and it finally worked when I used "_putenv" function in your lib to set the language.
Great stuff! Fredrik On Fri, Dec 3, 2010 at 2:46 PM, Dieter Verfaillie <[email protected]> wrote: > Quoting "Fredrik Corneliusson" <[email protected]>: >> >> I'm localizing a PyGTK application (win32 & py2exe). >> As my target audience is multilingual and might not want to have the >> user interface language set to the system default I have made it >> configurable. >> >> This works for the custom strings in my application but not for the >> built in GTK messages. You can change the locale by setting the LANG >> environment variable manually _before_ starting the application but >> that is sub optimal as the user selected locale is stored in a config >> file in users settings directory. >> Setting the environment variable after Python has started has no >> effect on GTK (even if I do it before loading any GTK modules). > > Starting with Python 2.4, changing os.environ only changes the copy of > the environment variables for Python. Processes on windows can have multiple > copies of the environment variables. In the case of a pygtk application > there's another copy maintained by the OS, one maintained by msvcr90 (the C > runtime used by Python) and depending on how your gtk+ runtime was built > there may be a copy for msvcrt (as is the case if you're using the binaries > from ftp.gnome.org). Thus you need to update all 4 copies for things to > work. > > I've written a module that solves the madness, you can find it on > https://github.com/dieterv/elib.intl/ (you'll need to clone the code, > there are no downloadable packages yet...) > > Read the inline docstrings of the install() and install_module() functions > to learn how to use elib.intl and the docstring of the _getscreenlanguage() > function to learn how the language to use is determined. Hint, we don't > look at the keyboard language but the actual screen language in use. Using > the keyboard language is a common error you'll see in a lot of other > software packages ported to windows that use gettext... > > mvg, > Dieter > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. > _______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
