Sorry,
I didn't have much time to look into it lately. Today I spent another
couple of hours trying to figure out why the translation doesn't work
for me.
I think the main problem is the path to my .mo file. This is the code I
now use for testing:
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import gettext
import locale
import os
if os.name == 'nt':
# windows hack for locale setting
lang = os.getenv('LANG')
print lang
if lang is None:
default_lang, default_enc = locale.getdefaultlocale()
if default_lang:
lang = default_lang
if lang:
os.environ['LANG'] = lang
locale.setlocale(locale.LC_ALL,'cz')
gettext.bindtextdomain("translate", "c:/Python/locale")
gettext.textdomain("translate")
_ = gettext.gettext
print gettext.find("translate")
The "find" function should return any matching .mo files. It returns
None. So I do believe that the problem is somewere in location of the
.mo file. It is in c:\python\locale\cs\LC_MESSAGES\translate.mo. Is it
possible to find out at which locations is the gettext extension looking
for the .mo files?
Thank you,
Vlada
Jarek Zgoda napsal(a):
Vláďa pisze:
Thank you for this suggestion, unfortunately it didn't change anything.
The function os.getenv('LANG') returns 'cs' for my system. So I do
believe the localization file should be placed in
locale\cs\LC_MESSAGES\translate.mo. But it doesn't work neither. Do you
have any other idea what could be wrong?
The Windows hack worked for me on W2k and XP with Polish locale, where
locale.getlocale() returned 'polish_poland'.
A working sample application would be a huge help for me.
See eg. http://svn.berlios.de/wsvn/jpa/branches/0.5/bin/jpa.py (I copied
the code from this module) or Gajim code
(http://trac.gajim.org/browser/trunk/src/common/i18n.py#L43 and onwards)
-- it is known to be working on Windows (and is much better established
than JPA ;)).
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/