Skip to content

Commit

Permalink
updating flask_babel fixes #2218 (#2359)
Browse files Browse the repository at this point in the history
* updating flask_babel fixes #2218

* changes according to #2218

* fixes according to release-notes

* black
  • Loading branch information
k9ert authored Jul 27, 2023
1 parent f8383ac commit 72fed92
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ chardet==3.0.4
Click==8.1.1
Flask==2.1.1
#Werkzeug==2.0.3 # need to pin because Flask doesn't work with newer ones
Flask-Babel==2.0.0 # needs pin see https://github.com/cryptoadvance/specter-desktop/issues/2218
Flask-Babel==3.1.0
Flask-Cors==3.0.10
Flask-Login==0.6.2
Flask-RESTful==0.3.9
Expand Down
13 changes: 6 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ apscheduler==3.10.0 \
--hash=sha256:575299f20073c60a2cc9d4fa5906024cdde33c5c0ce6087c4e3c14be3b50fdd4 \
--hash=sha256:a49fc23269218416f0e41890eea7a75ed6b284f10630dcfe866ab659621a3696
# via flask-apscheduler
babel==2.11.0 \
--hash=sha256:1ad3eca1c885218f6dce2ab67291178944f810a10a9b5f3cb8382a5a232b64fe \
--hash=sha256:5ef4b3226b0180dedded4229651c8b0e1a3a6a2837d45a073272f313e4cf97f6
babel==2.12.1 \
--hash=sha256:b4246fb7677d3b98f501a39d43396d3cafdc8eadb045f4a31be01863f655c610 \
--hash=sha256:cc2d99999cd01d44420ae725a21c9e3711b3aadc7976d6147f622d8581963455
# via flask-babel
base58==2.1.1 \
--hash=sha256:11a36f4d3ce51dfc1043f3218591ac4eb1ceb172919cebe05b52a5bcc8d245c2 \
Expand Down Expand Up @@ -180,9 +180,9 @@ flask==2.1.1 \
flask-apscheduler==1.12.4 \
--hash=sha256:681dae34dc6cc9403ce674795e53abd0bff540472129cfd3d3c93e0e1d502da8
# via -r requirements.in
flask-babel==2.0.0 \
--hash=sha256:e6820a052a8d344e178cdd36dd4bb8aea09b4bda3d5f9fa9f008df2c7f2f5468 \
--hash=sha256:f9faf45cdb2e1a32ea2ec14403587d4295108f35017a7821a2b1acb8cfd9257d
flask-babel==3.1.0 \
--hash=sha256:be015772c5d7f046f3b99c508dcf618636eb93d21b713b356db79f3e79f69f39 \
--hash=sha256:deb3ee272d5adf97f5974ed09ab501243d63e7fb4a047501a00de4bd4aca4830
# via -r requirements.in
flask-cors==3.0.10 \
--hash=sha256:74efc975af1194fc7891ff5cd85b0f7478be4f7f59fe158102e91abb72bb4438 \
Expand Down Expand Up @@ -664,7 +664,6 @@ pytz==2022.7.1 \
--hash=sha256:78f4f37d8198e0627c5f1143240bb0206b8691d8d7ac6d78fee88b78733f8c4a
# via
# apscheduler
# babel
# flask-babel
# flask-restful
# pandas
Expand Down
1 change: 1 addition & 0 deletions src/cryptoadvance/specter/htmlsafebabel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from flask_babel import Babel, get_translations
from jinja2.utils import markupsafe
import html
from flask import session, request


class HTMLSafeBabel(Babel):
Expand Down
4 changes: 2 additions & 2 deletions src/cryptoadvance/specter/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,13 @@ def inject_tor():
app.config["BABEL_TRANSLATION_DIRECTORIES"] = os.path.join(
sys._MEIPASS, "translations"
)
babel = HTMLSafeBabel(app)

@babel.localeselector
def get_language_code():
# Enables Babel to auto-detect current language
return app.get_language_code()

babel = HTMLSafeBabel(app, locale_selector=get_language_code)

@app.route("/set_language", methods=["POST"])
def set_language_code():
json_data = request.get_json()
Expand Down

0 comments on commit 72fed92

Please sign in to comment.