gettext newbie frustration

A

akbar

Hi, I try to learn gettext and python. This is the simple program
#simplehello.py
import locale
import gettext

APP = 'simplehello'
DIR = 'locale'
locale.setlocale(locale.LC_ALL, '')
gettext.bindtextdomain(APP, DIR)
gettext.textdomain(APP)
_ = gettext.gettext

print _('Hello World')

After that I do this in my shell:
$ xgettext -k_ -kN_ -o messages.pot simplehello.py
$ cp messages.pot de.po

Edit the de.po so it will be like this:
<snip>
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: simplehello.py:11
msgid "Hello World"
msgstr "blabla"

Then...
$ msgfmt de.po -o locale/de/LC_MESSAGES/simplehello.mo
$ msgfmt de.po -o locale/de_DE/LC_MESSAGES/simplehello.mo
$ msgfmt de.po -o locale/de_DE.UTF-8/LC_MESSAGES/simplehello.mo

I try to run the application:
$ LANG=de_DE.UTF-8 python simplehello.py

The output is still 'Hello World' not 'blabla'.
What's wrong?

Additional facts:
$ locale -a
C
de_AT.utf8
de_BE.utf8
de_CH.utf8
de_DE.utf8
de_LU.utf8
en_AU.utf8
<snip>

$ LANG=de_DE python simplehello.py
Traceback (most recent call last):
File "simplehello.py", line 6, in ?
locale.setlocale(locale.LC_ALL, '')
File "/usr/lib/python2.4/locale.py", line 381, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting

Thank you.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top