i18n questions

kyosohma at gmail.com kyosohma at gmail.com
Fri Dec 28 16:47:03 EST 2007


On Dec 28, 12:01 pm, Donn Ingle <donn.in... at gmail.com> wrote:
> Hi,
>  A soon-to-be happy new year to everyone!
>
> I'm 100% new to this i18n lark and my approach so far has been to create
> a .mo file per module in my app.
>  My thinking was, why load one huge .mo file when a single module only needs
> a few strings? Since then, it seems, I have made the wrong decision.
>
> For example I have module A that imports module B. Each one does this:
>
>     gettext.install( domain, localedir, unicode = True )
>     lang = gettext.translation(domain, localedir, languages = [ loc ] )
>     lang.install(unicode = True )
>
> (where doman is the name of the module, so "A" and "B")
>
> The problem is that domain "A" loads and then import B happens and so
> the "lang" reference (I think) gets replaced by domain "B" -- the result is
> that module A can only translate strings that are in domain "B".
>
> How does one 'merge' gettext.translations objects together? Or is that
> insane?
>
> What's the best way to handle a project with multiple domain.mo files?
>
> I hope someone can give me some advice.
>
> \d

I've never messed with .mo files, but a little "googling" turned up
this interesting module on PyPI: http://cheeseshop.python.org/pypi?%3Aaction=search&term=polib

If you're messing with unicode in general, I've heard this is a good
article to read:
http://kevino.theolliviers.com/python-unicode.html

This article looks related, although the author is using .po instead
of .mo files:
http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/

Finally, I found a wxPython specific one that looks like it might be
general enough for you:
http://wiki.wxpython.org/Internationalization

I hope that gives you some ideas anyway.

Mike



More information about the Python-list mailing list