gettext translate problem

Marek Wawrzyczek mwawrzyczek at gmail.com
Sat Aug 29 08:14:34 EDT 2009


Hi,

I've got the following code in main.py file:

import gettext
import os

t = gettext.translation(__file__.split('.')[0], os.getcwd())
_ = t.lgettext

if __name__=='__main__':
	print _("Hello")

then I call: xgettext main.py

and after that I call: msgfmt messages.po
wchich produces the following message:
messages.po: warning: Charset "CHARSET" is not a portable encoding
name.
                      Message conversion to user's charset might not
work.

then after calling: python main.py
the following output is print:
Traceback (most recent call last):
  File "main.py", line 4, in <module>
    t = gettext.translation(__file__.split('.')[0], os.getcwd())
  File "/usr/lib/python2.5/gettext.py", line 484, in translation
    raise IOError(ENOENT, 'No translation file found for domain',
domain)
IOError: [Errno 2] No translation file found for domain: 'main'

How to use gettext translation method properly?

Regards,
Marek



More information about the Python-list mailing list