[Tutor] Simple way for i18n ?
francois schnell
francois.schnell at gmail.com
Wed Mar 22 17:41:14 CET 2006
Hello all,
I wish to translate a Python script from English to French. I've read the
offical documentation (python.org doc) but I must admit that I'm lost now
...
I've found some simple explanations here but I can't make it work:
http://karrigell.sourceforge.net/en/internationalization.htm
Here's where I'm stuck:
Let's imagine my app is: myapp.py
--
import gettext
_ = gettext.gettext
print _("hello friends")
print _("Bye Bye")
---
Here are my folders on a windows box:
C:\myappfolder\
-----------------------\Translations\francais\LC_MESSAGES
My myapp.py is in myappfolder
In this folder I've used pygettext.py to produce a messages.pot file => I
add the translation in it => I have a messages.po file.
I then used msgfmt.py to produce messages.mo file.
I then copied messages.po and messages.mo in LC_MESSAGES folder
C:\myappfolder\
-----------------------\Translations\francais\LC_MESSAGES
I now come back to myapp.py and add two lines:
---
import gettext
_ = gettext.gettext
t=gettext.translation("messages","c:\myappfolder\Translations","francais")
t.install()
print _("hello friends")
print _("Bye Bye")
---
When I do that Python anwers:
>>>
Traceback (most recent call last):
File "C:\myappfolder\myapp.py", line 4, in ?
t=gettext.translation
("messages","c:\myappfolder\Translations","francais")
File "C:\Python24\lib\gettext.py", line 456, in translation
raise IOError(ENOENT, 'No translation file found for domain', domain)
IOError: [Errno 2] No translation file found for domain: 'messages'
>>>
I'm stuck here.
I understand it doesn't find the translation file but I can't figure out
why.
Can you tell me what I'm doing wrong or direct me to an URL (or a Python
book) where simple internationalisation for Python is gently explained
Thanks
francois (...from France)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060322/87f77031/attachment.html
More information about the Tutor
mailing list