Closed pythonstory closed 8 years ago
I moved @babel.localeselector
and @babel.timezoneselector
decorated function declaration into app/extensions.py
from app/app.py
so that they are not loaded.
It seems to be good, but I want to know a better way if you have. Thank you.
I know this is old and closed with some workaround but I found another. If you follow application structure with app factory then in your configure_extensions()
you can just check if babel.locale_selector_func
is not None
and set up .localeselector
only if it not set already.
Hello,
Flask-Babel extension works fine when it is run as an application, but I have a problem when running tests.
You can check the files related to Babel as follows:
app/app.py tests/test.py run.py babel.cfg test.cfg
I use Blueprints and
create_app()
factory.I tried to use
@classmethod
setUpClass
instead ofsetUp
to make sure that callapp.py
only once, but it doesn't work.I actually asked this issue at stackoverflow.com, but I didn't get answer at all.
Please, help me. What's wrong with me?