Beispiel #1
0
 def test_refreshing(self):
     app = flask.Flask(__name__)
     b = babel.Babel(app)
     d = datetime(2010, 4, 12, 13, 46)
     with app.test_request_context():
         assert babel.format_datetime(d) == 'Apr 12, 2010 1:46:00 PM'
         app.config['BABEL_DEFAULT_TIMEZONE'] = 'Europe/Vienna'
         babel.refresh()
         assert babel.format_datetime(d) == 'Apr 12, 2010 3:46:00 PM'
Beispiel #2
0
 def test_refreshing(self):
     app = flask.Flask(__name__)
     b = babel.Babel(app)
     d = datetime(2010, 4, 12, 13, 46)
     with app.test_request_context():
         assert babel.format_datetime(d) == 'Apr 12, 2010 1:46:00 PM'
         app.config['BABEL_DEFAULT_TIMEZONE'] = 'Europe/Vienna'
         babel.refresh()
         assert babel.format_datetime(d) == 'Apr 12, 2010 3:46:00 PM'
Beispiel #3
0
def set_locale():
    nlocale = request.form['code']
    redirect_way = request.form['redirect']
    session['locale'] = nlocale
    if current_user.is_authenticated():
        current_user.locale = nlocale
        db.session.add(current_user)
        db.session.commit()
    refresh()
    return redirect(redirect_way)
Beispiel #4
0
def set_locale():
    nlocale = request.form['code']
    redirect_way = request.form['redirect']
    session['locale'] = nlocale
    if current_user.is_authenticated():
        current_user.locale = nlocale
        db.session.add(current_user)
        db.session.commit()
    refresh()
    return redirect(redirect_way)
Beispiel #5
0
def language(lang_code):
    '''Force a given language'''
    ctx = None
    if not request:
        ctx = current_app.test_request_context()
        ctx.push()
    backup = g.get('lang_code')
    g.lang_code = lang_code
    refresh()
    yield
    g.lang_code = backup
    if ctx:
        ctx.pop()
    refresh()
Beispiel #6
0
def language(lang_code):
    '''Force a given language'''
    ctx = None
    if not request:
        ctx = current_app.test_request_context()
        ctx.push()
    backup = g.get('lang_code')
    g.lang_code = lang_code
    refresh()
    yield
    g.lang_code = backup
    if ctx:
        ctx.pop()
    refresh()
Beispiel #7
0
def set_locale():
    # user.timezone = request.form['timezone']
    # user.locale = request.form['locale']
    refresh()
    # flash(gettext('Language was changed'))
    return render_template('index.html')