python locale for gtk does not work on windows

安稳与你 提交于 2019-12-03 16:31:04

This is becoming a common question these days and should probably become a PyGTK FAQ. See for example this PyGTK bug report

In short, there's a whole lot of details you're missing. For example:

1) Starting with Python 2.4, on Windows, assigning values to os.environ only changes the copy of the environment variables Python manages and no longer has any effect on the copy maintained by the C library (msvcr90 for Python, msvcrt for the various GTK+ related dll's).

2) Once you take care of the above you also need to take special care of configuring libintl. That means you'll need to bindtextdomain() and bind_textdomain_codeset() both intl.dll and Python's gettext module.

There's probably more that I don't remember right now, but you could take a look at my elib.intl module written specifically for what you're trying to do (and more). When you have it working, you can simply set the LANGUAGE environment variable to C to have the default American English.

You can do that either from a .bat or .cmd file or by using os.environ['LANGUAGE'] = 'C' befory you import elib.intl.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!