I have a problem trying to internationalize a simple file in Python.
the main folder is called "simple"
here is the file:
hello.py
------------------------------------
Expand|Select|Wrap|Line Numbers
- import os,sys
- import gettext
- #i18n
- pathname = os.path.dirname(sys.argv[0])
- localedir = os.path.abspath(pathname) + "\locale"
- gettext.install("messages", localedir, unicode=1)
- print gettext
- print pathname
- print localdir
- print gettext.install("messages", localedir, unicode=1)
- print _("hello")
- print _("Nice to meet you")
- ---------------------------------------
the result is:
<module 'gettext' from 'C:\Python24\lib\gettext.pyc'>
C:\Documents and Settings\Alex\Bureau\simple
C:\Documents and Settings\Alex\Bureau\simple\locale
None
hello
Nice to meet you
### It looks like it doesn't install anything! but why?
my "messages.po"/"messages.mo" are in folders like these:
\simple\locale\en_GB\LC_MESSAGES
\simple\locale\fr_FR\LC_MESSAGES
###here is an example of my po file
-----------------------------------------------
# French translations for PACKAGE package.
# Copyright (C) 2007 ORGANIZATION
# Alex <EMAIL@ADDRESS>, 2007.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2007-07-19 09:45+Paris, Madrid (heure d'été)\n"
"PO-Revision-Date: 2007-07-19 09:52+0200\n"
"Last-Translator: Alex <EMAIL@ADDRESS>\n"
"Language-Team: French\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CP1252\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: C:\Documents and Settings\Alex\Bureau\simple\hello.py:14
msgid "hello"
msgstr "Salut"
#: C:\Documents and Settings\Alex\Bureau\simple\hello.py:16
msgid "Nice to meet you"
msgstr "Heureux de faire votre connaissance"
---------------------------------------------
(I am runnnig Windows XP)
I am on it for 3 days now , and I don't know what to do.
It would be wondeful if someone could have an idea or advice about this.
thx
Alex