Pastebin

Paste #3195: No description

< previous paste - next paste>

Pasted by Anonymous Coward

Download View as text

@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


Do not write anything in this field if you're a human.

Go to most recent paste.