开发者

How to use my own locale for pyGTK?

I'm writing a soft using pyGTK. I'd like to know how to force pyGTK to use my own *.mo files for GTK.

In fact my problem is, I code under Linux but I want to distribute it under Windows. To get a Windows executable, I use cx_Freeze, I can include my own gettext for my texts and it's work well, but I want to include pyGTK gettext too, because if I don't to that text on button are still in English even the Windows is in different language. And since I don't want to support all GTK languages, I don't want to includes all languages.

Thanks in advance and sorry for the bad english...

EDiT: Since a code snippet is better than anything:

APP_NAME="MyWonderfulApp"
LOCALE_DIR="locale"
#Translation stuff

local_path = os.path.realpath(os.path.dirname(sys.argv[0]))
langs = []
lc, encoding = locale.getdefaultlocale()
if (lc):
    langs = [lc]

language = os.environ.get('LANGUAGE', None)
if (language):
    langs += language.split开发者_C百科(":")

langs += ["fr_FR", "en_US"]
gettext.bindtextdomain(APP_NAME, LOCALE_DIR)
gettext.textdomain(APP_NAME)
lang = gettext.translation(APP_NAME, LOCALE_DIR, languages=langs, fallback = True)
_ = lang.gettex


You're initializing Python's gettext correctly, but not libintl which is used by GTK+ and friends. You could take a look at my elib.intl module to see how that's done.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜