from flask import redirect, request, session
from flask.ext.babel import refresh
from config import BABEL_DEFAULT_LOCALE
from ..views import BaseView, expose

from app import babel


class LocaleView(BaseView):
    route_base = '/lang'

    @expose('/<string:locale>')
    def index(self, locale):
        session['locale'] = locale
        refresh()
        return redirect(self._get_redirect())


@babel.localeselector
def get_locale():
    locale = session.get('locale')
    if locale:
        return locale
    session['locale'] = BABEL_DEFAULT_LOCALE
    return session['locale']

@@ -78,48 +78,8 @@
 esh%0A
-from config import BABEL_DEFAULT_LOCALE%0A
 from
@@ -116,31 +116,8 @@
 se%0A%0A
-from app import babel%0A%0A
 %0Acla
@@ -333,190 +333,4 @@
 )%0A%0A%0A
-@babel.localeselector%0Adef get_locale():%0A    locale = session.get('locale')%0A    if locale:%0A        return locale%0A    session%5B'locale'%5D = BABEL_DEFAULT_LOCALE%0A    return session%5B'locale'%5D%0A

Update views.py