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
|
# Configure translation directory
|
||||||
app.config['BABEL_TRANSLATION_DIRECTORIES'] = 'translations'
|
app.config['BABEL_TRANSLATION_DIRECTORIES'] = 'translations'
|
||||||
|
|
||||||
@babel.localeselector
|
@babel.locale_selector
|
||||||
def get_locale():
|
def get_locale():
|
||||||
# Try to get language from URL parameter
|
# Try to get language from URL parameter
|
||||||
lang = request.args.get('lang')
|
lang = request.args.get('lang')
|
||||||
|
|
@ -41,7 +41,6 @@ def get_locale():
|
||||||
# Context processor to make language and config available in templates
|
# Context processor to make language and config available in templates
|
||||||
@app.context_processor
|
@app.context_processor
|
||||||
def inject_global_variables():
|
def inject_global_variables():
|
||||||
from flask import request
|
|
||||||
lang = get_locale()
|
lang = get_locale()
|
||||||
return {
|
return {
|
||||||
'language': lang,
|
'language': lang,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue