Re: PyGTK localisation on Win32



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
.



Relevant Pages

  • LANG, locale, unicode, setup.py and Debian packaging
    ... On start I call locale.setlocale, the getlocale. ... The app assumes unicode objects internally. ... My setup.py also tests locale (because it then loads gettext ... happens if LANG is set to "C", ...
    (comp.lang.python)
  • Re: PyGTK localisation on Win32
    ... I had no problem with using standard gettext way of doing i18n on ... apart some quirks with LANG environment ... defaultLang, defaultEnc = locale.getdefaultlocale ...
    (comp.lang.python)
  • Re: need kestroke logger source code - will pay $$$ for it....
    ... > i need and will pay for a simple app that logs keystrokes, ... > coders... ... but will another lang allow that?) ...
    (comp.security.misc)
  • Locale LC_ALL=""
    ... Within my app I get an error "Cannot set locale to ''." ... Variable LANG is set in the environment file to "en". ... To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org ...
    (Debian-User)
  • Re: Q about Making Subfolders in the Applications Folder
    ... Shawn Hirn wrote: ... But if I need an app that isn't in the Dock I use ... Lang may your lum reek. ...
    (comp.sys.mac.apps)