[pygtk] libglade internationalization
Jarek Zgoda
jzgoda at o2.pl
Tue May 16 03:44:28 WST 2006
simd at arcor.de napisał(a):
> Hello all, I'm trying to get a python freeware package for windows
> from Sourceforge to work in my locale (de_DE). It uses pyGtk under
> windows with Glade for the forms, and appears to do everything
> correctly. It works correctly in Linux, and under Windows the
> strings in the code which use the standard gettext method translate
> ok. But the glade forms did not translate under Windows.
>
> However I then tried copying the application.po file into the
> subdirectory not ".....\de_DE\LC_MESSAGES\", but instead
> ".....\de\LC_MESSAGES\". And it worked fine!
>
> So it appears that libglade for Windows maybe can't handle language
> dialects correctly. Is this to be expected? Does anyone know what is
> happening and can help? Is it possible to confirm exactly where
> libglade is looking for the translation files in my Windows
> environment? Or exactly which environment variables/settings are
> checked? Or how it deals with Microsoft's non-unix locale responses?
> Nothing in the FAQ appears to answer this case exactly.
Windows sometimes behaves... differently. In most cases Windows has
problems with handling canonical names of locales. You can try some
dirty trick to ensure that your program will not choke on Windows.
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
This was required, because Windows wanted canonical name
"Polish_Poland", not "pl_PL", or even "pl".
--
Jarek Zgoda
http://jpa.berlios.de/
More information about the pygtk
mailing list