17 Apr
2009
17 Apr
'09
7:46 p.m.
Ethan Jucovy wrote:
How about just monkeypatching the active negotiator?
{{{ negotiator = getUtility(zope.i18n.interfaces.INegotiator) orig = negotiator.getLanguage negotiator.getLanguage = lambda foo, bar: 'fr' text = my_page_template() negotiator.getLanguage = orig }}}
Haven't tested it, but in my (limited) understanding of the I18N system something like that ought to work..
As the default negotiator is based on the request, it might be possible to forge a different request object for the template. Or attach a marker interface to the request and register a different IUserPreferredLanguages adapter for it. A more specialized version should take precedence over the normal adapter based on the HTTP header. Hanno