[I18n-sig] Problem using gettext

Philippe Collet philopensource at hotmail.com
Tue May 17 10:42:30 CEST 2005


Hi list,
Hope i'm in the good list.
I'm having problem using gettext.
import gettext
domain = 'test'
dir='C:\\Documents and Settings\\Philippe\\Bureau\\test'
lang = 'fr'
t=gettext.translation(domain,dir,lang)

I generated with pygettext.py the .pot file, i fill the msgstr line. I 
rename it in test.po and i generate the .mo file with msgfmt.py.

I'm sure the following path is correct.
C:\Documents and Settings\Philippe\Bureau\test\fr\LC_MESSAGES\test.mo.

I'm having next error:

Traceback (most recent call last):
  File 
"C:\Python23\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", 
line 310, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\Documents and Settings\Philippe\Bureau\test\test.py", line 6, in 
?
    t=gettext.translation(domaine,repBase)
  File "C:\Python23\lib\gettext.py", line 405, in translation
    raise IOError(ENOENT, 'No translation file found for domain', domain)
IOError: [Errno 2] No translation file found for domain: 'test'.

My Python version: ActiveState ActivePython 2.3.5
OS: Window XP SP2

I think there is a problem in the find function because it's returning 
always None, even if the path is correct and the file .mo found.

I tryed to use directly the find function in the gettext.py file without 
success
>>>print gettext.find(domain, dir, lang)
None

By inspecting this function i tryied to test the validity of the path:
>>>if os.path.exists(os.path.join(dir, lang, 'LC_MESSAGES', '%s.mo' % 
>>>domain)):
...     print 'ok'
...
ok

Can anyone help me please?,
Philippe Collet

_________________________________________________________________
MSN Messenger : discutez en direct avec vos amis ! 
http://www.msn.fr/msger/default.asp



More information about the I18n-sig mailing list