gettext translate problem

M

Marek Wawrzyczek

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,001
Latest member
Kendra00E1

Latest Threads

Top