commit 0f8b783300f331779368184403829374f8064b56
parent f6387885d49a0261323dc1d8653944624453b81a
Author: Florian Dold <florian@dold.me>
Date: Thu, 30 Oct 2025 11:46:30 +0100
make translations work with latest python babel flask
Diffstat:
4 files changed, 5 insertions(+), 25 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
@@ -36,10 +36,10 @@ include = [
[tool.poetry.dependencies]
python = "^3.8"
-Flask = "^2.0.2"
+Flask = "^3.1.1"
requests = "^2.26.0"
beautifulsoup4 = "^4.10.0"
-Flask-Babel = "^2.0.0"
+Flask-Babel = "^4.0.0"
gunicorn = "^23.0.0"
[tool.poetry.dev-dependencies]
diff --git a/talermerchantdemos/blog/blog.py b/talermerchantdemos/blog/blog.py
@@ -75,14 +75,6 @@ BABEL_TRANSLATION_DIRECTORIES = "../translations"
app.config.from_object(__name__)
babel = Babel(app, locale_selector=get_locale)
-logger.info("Using translations from:" + ":".join(list(babel.translation_directories)))
-translations = [str(translation) for translation in babel.list_translations()]
-if not "en" in translations:
- translations.append("en")
-logger.info(
- "Operating with the following translations available: " + " ".join(translations)
-)
-
# Add context processor that will make additional variables
# and functions available in the template.
app.context_processor(
@@ -157,6 +149,7 @@ def internal_error(e):
@app.route("/")
def index():
default = "en"
+ translations = [x.language for x in babel.list_translations()]
target = flask.request.accept_languages.best_match(translations, default)
return flask.redirect(url_for("index") + target + "/", code=302)
diff --git a/talermerchantdemos/donations/donations.py b/talermerchantdemos/donations/donations.py
@@ -81,14 +81,7 @@ if donau_url:
donau_url = None
-logger.info("Using translations from:" + ":".join(list(babel.translation_directories)))
logger.info("currency: " + CURRENCY)
-translations = [str(translation) for translation in babel.list_translations()]
-if not "en" in translations:
- translations.append("en")
-logger.info(
- "Operating with the following translations available: " + " ".join(translations)
-)
# Add context processor that will make additional variables
# and functions available in the template.
@@ -184,6 +177,7 @@ def favicon():
@app.route("/")
def index():
default = "en"
+ translations = [x.language for x in babel.list_translations()]
target = flask.request.accept_languages.best_match(translations, default)
return flask.redirect(url_for("index") + target + "/", code=302)
diff --git a/talermerchantdemos/landing/landing.py b/talermerchantdemos/landing/landing.py
@@ -60,14 +60,6 @@ app.config.from_object(__name__)
babel = Babel(app, locale_selector=get_locale)
-LOGGER.info("Using translations from:" + ":".join(list(babel.translation_directories)))
-translations = [str(translation) for translation in babel.list_translations()]
-if not "en" in translations:
- translations.append("en")
-LOGGER.info(
- "Operating with the following translations available: " + " ".join(translations)
-)
-
# Add context processor that will make additional variables
# and functions available in the template.
app.context_processor(
@@ -112,6 +104,7 @@ def favicon():
@app.route("/")
def index():
default = "en"
+ translations = [x.language for x in babel.list_translations()]
target = flask.request.accept_languages.best_match(translations, default)
return flask.redirect(url_for("index") + target + "/", code=302)