PyGTK localisation on Win32

J

jwesonga

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?
 
J

Jarek Zgoda

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.
 
S

Sukhov Dmitry

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top