gettext translate problem

Marek Wawrzyczek mwawrzyczek at
Sat Aug 29 14:14:34 CEST 2009


I've got the following code in file:

import gettext
import os

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

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

then I call: xgettext

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

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

How to use gettext translation method properly?


More information about the Python-list mailing list