By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,767 Members | 1,995 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,767 IT Pros & Developers. It's quick & easy.

PyGTK localisation on Win32

P: n/a
I've built an app on linux which we have managed to localise into at
least three languages, the app runs well using this command LANG=fr_FR
python app.py which would translate the app into french. We've tried
the replicate the same principle on windows but so far nothing works,
the app will need to be translated into other languages that have no
locale, in windows is there a way to have Glade load values from a
textfile instead of trying to use the .mo files?
Mar 25 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
jwesonga pisze:
I've built an app on linux which we have managed to localise into at
least three languages, the app runs well using this command LANG=fr_FR
python app.py which would translate the app into french. We've tried
the replicate the same principle on windows but so far nothing works,
the app will need to be translated into other languages that have no
locale, in windows is there a way to have Glade load values from a
textfile instead of trying to use the .mo files?
I had no problem with using standard gettext way of doing i18n on
Windows with PyGTK an Glade, apart some quirks with LANG environment
variable. Basically, the code that works looks like this:

import gettext, locale
locale.setlocale(locale.LC_ALL, '')
if os.name == 'nt':
# windows hack for locale setting
lang = os.getenv('LANG')
if lang is None:
defaultLang, defaultEnc = locale.getdefaultlocale()
if defaultLang:
lang = defaultLang
if lang:
os.environ['LANG'] = lang
gtk.glade.bindtextdomain(appname, translation_dir)
gtk.glade.textdomain(appname)
gettext.install(appname, translation_dir, unicode=True)

Be aware, that you can not change the locale setting from the command
line like you do on Linux.

--
Jarek Zgoda
http://zgodowie.org/

"We read Knuth so you don't have to" - Tim Peters
Mar 25 '08 #2

P: n/a
>
I had no problem with using standard gettext way of doing i18n on
Windows with PyGTK an Glade, apart some quirks with LANG environment
variable. Basically, the code that works looks like this:

import gettext, locale
locale.setlocale(locale.LC_ALL, '')
if os.name == 'nt':
# windows hack for locale setting
lang = os.getenv('LANG')
if lang is None:
defaultLang, defaultEnc = locale.getdefaultlocale()
if defaultLang:
lang = defaultLang
if lang:
os.environ['LANG'] = lang
gtk.glade.bindtextdomain(appname, translation_dir)
gtk.glade.textdomain(appname)
gettext.install(appname, translation_dir, unicode=True)

Be aware, that you can not change the locale setting from the command
line like you do on Linux.
I have the same problem. I did all as you wrote. gettext translations
do work fine. But translations in glade does not work.

The only way to turn it on is to set environment variable LANG
explicitly before program run:
set LANG=ru_RU
python test.py
Mar 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.