stas at tuxzilla.tuxhome
Mon Aug 8 20:14:52 CEST 2005
On Mon, 08 Aug 2005 17:39:34 +0200, cantabile wrote:
> BTW stasz,
> Maybe you'll have still some time for the following question. Trying my
> luck :))
> Suppose I have several units (.py files), say test.py test1.py tets2.py
> , test.py being my main file.
> I've read I can import gettext and install in the main unit. Then, must
> I create .po files for each unit or is there a way to make a single .po
> file for the whole app. ?
Yes there is.
As a reminder, make sure that you install gettext in the namespace
of your toplevel module.
What I mean is this:
test1.py imports test2.py and test3.py
test2.py imports test4.py
Now you have to place the gettext.install call in test1.py and
then the other modules can access it.
If you place the gettext call in, for example, test2.py then only
test2.py and test4.py have access to it.
So when it don't work as you expect make sure to check if every
module has access to the "_" from gettext.
So now for your question about one po/mo file for multiple
I use this file for a project of mine it also includes some
explanation in case I forget it myself :-)
The project is called "Guido van Robot".
The files mentioned inside this file are used in the above project
and serve as an example in this case.
You could replace the files with your own to try it.
The file itself is called "FilesForTrans" so you could put this
file together with your test modules inside a directory and follow
the instructions in side "FilesForTrans".
Contents of "FilesForTrans"
---- cut here ---------
## These files contain i18n strings
## Use: xgettext -f ./FilesForTrans -p /tmp
## The message.po will be located in /tmp
## Now do: msgmerge ./po/nl/gvr.po /tmp/messages.po > /tmp/new_nl.po
## compile the .po to mo (place the .po after editing in ./po/nl/)
## msgfmt ./po/nl/gvr.po -o ./locale/nl/LC_MESSAGES/gvr.mo
More information about the Python-list