fix(i18n): use babel.locale_selector instead of babel.localeselector for Flask-Babel 4.0.0
- Flask-Babel 4.0.0 changed the API - @babel.localeselector -> @babel.locale_selector - Remove redundant request import in context processor - All tests still pass
This commit is contained in:
parent
34dd3ca937
commit
6282bb9789
1 changed files with 1 additions and 2 deletions
3
app.py
3
app.py
|
|
@ -26,7 +26,7 @@ app.config['LANGUAGES'] = {
|
|||
# Configure translation directory
|
||||
app.config['BABEL_TRANSLATION_DIRECTORIES'] = 'translations'
|
||||
|
||||
@babel.localeselector
|
||||
@babel.locale_selector
|
||||
def get_locale():
|
||||
# Try to get language from URL parameter
|
||||
lang = request.args.get('lang')
|
||||
|
|
@ -41,7 +41,6 @@ def get_locale():
|
|||
# Context processor to make language and config available in templates
|
||||
@app.context_processor
|
||||
def inject_global_variables():
|
||||
from flask import request
|
||||
lang = get_locale()
|
||||
return {
|
||||
'language': lang,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue