Re: Internationalizing a module-application like a module or like an application?

"Martin v. Löwis" <[email protected]> Thu, 19 May 2005 22:29:53 +0200
Newsgroups gmane.comp.python.internationalization
Message-ID <[email protected]>
Philippe Collet wrote:
> I don't know if i have to internationalize it like a module or like an 
> application, regarded to
> python.active-venture.com/lib/node276.html.
> Is anyone having any idea?

You can *always* use gettext in the "like a module" mode, even for
applications. The only disadvantage is that you have to modify every
module; for the "application" case, you override the global _, so
it automatically applies to all modules in the application.

If you have multiple .py files, and if one of them is somehow
a config/setup file (say, "mysetup.py"), you could write into
all other modules

from mysetup import _

and into mysetup.py

import gettext
t = gettext.translation('spam', '/usr/share/locale')
_ = t.gettext

Regards,
Martin