[TransWarp] internationalization

Phillip J. Eby pje at telecommunity.com
Tue Jun 24 08:49:01 EDT 2003

At 10:59 AM 6/24/03 +0200, Radek Kanovsky wrote:

>I have searched through the web for some smart solution but haven't found

Have you looked at Zope 3's 'zope.i18n' package?  Also, I believe GNU 
gettext has support for declaring different translations of the same string 
based on a numeric value formula.

>My idea is that i18n subsystem should be adaptable (at least)
>to following interface:
>     class IMessageCatalog (Interface) :
>         def lookup(msg_id, language, **named_parameters) :
>             """Returns message according to msgi_id in given language
>                with substituted named_parameters.
>             """
>It is programmer's work to create some shortcut methods that resolve
>catalog, msg_id or language from some context provided by application
>(HTTPRequest object, configuration, session, __name__ or such).

Presently, I'm assuming that we will mostly activate translation via a 
'view="translate"' attribute in an HTML template, to translate either a 
piece of constant text in the template, or to translate a piece of variable 
data such as a menu item title.  I hadn't given any thought to 
interpolation, but of course supporting that would be a good idea too.

I'd like to reuse zope.i18n where possible, since it has a nice locales 
database built in, with support for timezones, date/time/numeric/currency 
formats, etc.  So we will probably use their interfaces where 
applicable.  We probably won't be doing this for our first few 
applications, though, which will be targeted to test more basic parts of 
the web framework such as traversal, security, and templates.

More information about the PEAK mailing list