i18n questions
Thorsten Kampe
thorsten at thorstenkampe.de
Sat Dec 29 10:44:28 EST 2007
* Donn Ingle (Fri, 28 Dec 2007 20:01:48 +0200)
> 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 can give you just general advice how I dealt with
internationalization in my example app. "scipt" is the main app with
its own mo file and imports optparse which has again its own mo file
#
gettext.textdomain('optparse')
gettext.install('script', unicode = True)
from optparse import OptionParser, \
OptionGroup
# [...]
Thorsten
More information about the Python-list
mailing list