Pastebin
Paste #3195: No description
< previous paste - next paste>
Pasted by Anonymous Coward
@babel.localeselector def get_locale(): # if a user is logged in, use the locale from the user settings user = getattr(g, 'user', None) if user is not None and hasattr(user, 'locale'): print "get_locale: user.locale %s" % user.locale return user.locale # otherwise try to guess the language from the user accept header # we support en/da/de print "get_locale: request.accept_languages.best_match: %s" % (request.accept_languages.best_match(LANGUAGES.keys())) return request.accept_languages.best_match(LANGUAGES.keys())
New Paste
Go to most recent paste.