def get_locale():
     misc = Misc.query.first()
     if misc and misc.language != '':
         for key in LANGUAGES:
             if key == misc.language:
                 return key
     return request.accept_languages.best_match(LANGUAGES.keys())
Exemplo n.º 2
0
 def get_locale():
     misc = db_retrieve_table(app.config['MYCODO_DB_PATH'],
                              Misc,
                              entry='first')
     if misc.language != '':
         for key, _ in LANGUAGES.iteritems():
             if key == misc.language:
                 return key
     return request.accept_languages.best_match(LANGUAGES.keys())
Exemplo n.º 3
0
 def get_locale():
     try:
         user = User.query.filter(
             User.id == flask_login.current_user.id).first()
         if user and user.language != '':
             for key in LANGUAGES:
                 if key == user.language:
                     return key
     # Bypass endpoint test error "'AnonymousUserMixin' object has no attribute 'id'"
     except AttributeError:
         pass
     return request.accept_languages.best_match(LANGUAGES.keys())
Exemplo n.º 4
0
 def get_locale():
     try:
         user = User.query.filter(
             User.id == flask_login.current_user.id).first()
         if user and user.language != '':
             for key in LANGUAGES:
                 if key == user.language:
                     return key
     # Bypass endpoint test error "'AnonymousUserMixin' object has no attribute 'id'"
     except AttributeError:
         pass
     return request.accept_languages.best_match(LANGUAGES.keys())