Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
PonteIneptique authored Mar 6, 2024
1 parent dbeef55 commit 7ec39c2
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ def create_app(config_name="dev"):
compress.init_app(app)
md = Markdown(app, safe_mode=True)
babel.init_app(app, locale_selector=get_locale)
"""if db.session.get_bind().dialect.name == "postgresql":
lc_messages_query = db.session.execute(text("SHOW lc_messages;"))
psql_locale = lc_messages_query.fetchone()[0]
if psql_locale != "en_US.UTF-8":
warnings.warn("Your postgresql instance language is not english. Switching to English.")
db.session.execute(text("SET lc_messages TO 'en_US.UTF-8';"))
db.session.commit()"""
with app.app_context():
if db.session.get_bind().dialect.name == "postgresql":
lc_messages_query = db.session.execute(text("SHOW lc_messages;"))
psql_locale = lc_messages_query.fetchone()[0]
if psql_locale != "en_US.UTF-8":
# ToDo: add an option in config.py to check something such as app.config["FORCE_PSQL_EN_LOCALE"] (with default on True)
warnings.warn("Your postgresql instance language is not english. Switching to English.")
db.session.execute(text("SET lc_messages TO 'en_US.UTF-8';"))
db.session.commit()
# Register Jinja template functions
from .main import main as main_blueprint
app.register_blueprint(main_blueprint)
Expand Down

0 comments on commit 7ec39c2

Please sign in to comment.