From 7cc8b9b52d8121c16f19e44a3ece5cc3302f4d25 Mon Sep 17 00:00:00 2001 From: Daniel Tsvetkov Date: Mon, 25 Oct 2021 08:38:17 +0200 Subject: [PATCH] translations fix --- bootstrap/run.py | 6 ++++-- oshipka.sh | 7 +++++++ oshipka/persistance/__init__.py | 5 +++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bootstrap/run.py b/bootstrap/run.py index 15d7b81..a39c1a4 100644 --- a/bootstrap/run.py +++ b/bootstrap/run.py @@ -1,4 +1,4 @@ -from config import TEMPLATES_FOLDER, STATIC_FOLDER +from config import TEMPLATES_FOLDER, STATIC_FOLDER, APP_BASE_URL, PORT from oshipka.persistance import populate_static, init_db from populate import populate_db @@ -12,4 +12,6 @@ app.template_folder = TEMPLATES_FOLDER app.static_folder = STATIC_FOLDER if __name__ == "__main__": - app.run(port=5000, debug=True, ssl_context=('webapp/ssl/cert.crt', 'webapp/ssl/cert.key')) + print("Running on {}".format(APP_BASE_URL)) + app.run(port=PORT, debug=True, ssl_context=('webapp/ssl/cert.crt', 'webapp/ssl/cert.key')) + diff --git a/oshipka.sh b/oshipka.sh index 79b13e5..014b799 100755 --- a/oshipka.sh +++ b/oshipka.sh @@ -214,6 +214,13 @@ bootstrap() { python manager.py db migrate -m "001" _post_migrate python manager.py db upgrade + + command_translate "" extract + command_translate "" gen en + # TODO: sed acts on a line-by-line +# sed -i 's/msgid "Project"/msgstr ${PROJECT_NAME}/' translations/en/LC_MESSAGES/messages.po + command_translate "" compile + git init . git add . git commit -m "Initial commit" diff --git a/oshipka/persistance/__init__.py b/oshipka/persistance/__init__.py index 332a1af..a666b99 100644 --- a/oshipka/persistance/__init__.py +++ b/oshipka/persistance/__init__.py @@ -275,8 +275,8 @@ def register_index_svc(): def _init_translations(app): - from flask_babelex import Babel - babel = Babel(app) + from flask_babelex import Babel, gettext, Domain + babel = Babel(app, default_domain=Domain(dirname='translations')) @babel.localeselector def get_locale(): @@ -298,6 +298,7 @@ def init_db(app): app.config["SQLALCHEMY_DATABASE_URI"] = SQLALCHEMY_DATABASE_URI app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False app.config["WHOOSH_BASE"] = SEARCH_INDEX_PATH + app.config["BABEL_TRANSLATION_DIRECTORIES"] = '/translations' try: from config import TRANSLATION_LANGUAGES app.config["TRANSLATION_LANGUAGES"] = TRANSLATION_LANGUAGES