Skip to content

Instantly share code, notes, and snippets.

@jensens
Created May 3, 2011 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jensens/953532 to your computer and use it in GitHub Desktop.
Save jensens/953532 to your computer and use it in GitHub Desktop.
from Products.Five.browser import BrowserView
class LangRedir(BrowserView):
"""language redirect"""
def __call__(self):
target = 'en-ie'
for lang in self.context.portal_languages.getRequestLanguages():
if lang in ('de-at', 'de-ch'):
target = 'de-at'
break
if lang == 'de-de' or lang.startswith('de'):
target = 'de-de'
break
if lang.startswith('es'):
target = 'es-es'
break
if lang.startswith('it'):
target = 'it-it'
break
if lang.startswith('pl'):
target = 'pl'
break
if lang.startswith('en'):
target = 'en-ie'
break
url = self.context.portal_url() + '/' + target
return self.request.response.redirect(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment