[Grok-dev] How to force language settings in Grok, overriding browser settings
Sebastian Ware
sebastian at urbantalk.se
Thu Jan 5 14:07:27 UTC 2012
Hi everybody!
I just want to add this piece of code since I have tried to figure this out for a couple of years... :D but solved it now and it might save someone some time...
In order to force the language settings (in my case the settings are in the page in a multilingual site), I use the following code:
import grok
from zope.i18n.interfaces import IModifiableUserPreferredLanguages
class MyView(grok.View):
def update(self):
language = self.context.language # Language settings stored in context,
# iso-two letter style "sv", "en"
mupl = IModifiableUserPreferredLanguages(self.request)
mupl.setPreferredLanguages((language,))
Still dreaming about the Grok cookbook... :D
Mvh Sebastian
More information about the Grok-dev
mailing list