def monkey(): # get the services that has been registered so far and plug in our # new one global _fallback_translation_service _fallback_translation_service = \ GTS.setGlobalTranslationService(fiveTranslationService) # now override the getter/setter so that noone else can mangle # with it anymore GTS.getGlobalTranslationService = getGlobalTranslationService GTS.setGlobalTranslationService = setGlobalTranslationService
class PTSLanguages(object): """Languages adapter that chooses languages like PlacelessTranslationService.""" implements(IUserPreferredLanguages) def __init__(self, context): self.context = context def getPreferredLanguages(self): from Products.PlacelessTranslationService.Negotiator import getLangPrefs return getLangPrefs(self.context) # these are needed for the monkey _fallback_translation_service = GTS.DummyTranslationService() fiveTranslationService = FiveTranslationService() def getGlobalTranslationService(): return fiveTranslationService def setGlobalTranslationService(newservice): global _fallback_translation_service oldservice, _fallback_translation_service = \ _fallback_translation_service, newservice return oldservice def monkey():