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"):
return user.locale
translations = [str(translation) for translation in babel.list_translations()]
return request.accept_languages.best_match(translations)
评论列表
文章目录