From 9cbf35644489b1144c23f154b5e00e3d1e56a0cd Mon Sep 17 00:00:00 2001 From: Kiril Kovachev Date: Tue, 15 Oct 2024 16:52:22 +0100 Subject: [PATCH] Begin translation subsystem page --- kanken_online/__init__.py | 15 +++++++++++++++ kanken_online/lang.py | 9 ++++++--- kanken_online/templates/translations.html | 19 +++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 kanken_online/templates/translations.html diff --git a/kanken_online/__init__.py b/kanken_online/__init__.py index 65463e2..284616b 100644 --- a/kanken_online/__init__.py +++ b/kanken_online/__init__.py @@ -74,6 +74,21 @@ def create_app(test_config=None): def kotoba_page(kotoba: str): return render_template("kotoba.html", kotoba=kotoba) + @app.route("/translations", methods=["GET", "POST"]) + def strings_translation(): + if request.method == "GET": + strings = {} + for language, language_data in lang.LANGUAGES.items(): + strings[language] = { + string: translation for string, translation in language_data.items() + } + + return render_template("translations.html", strings=strings) + else: + # TODO + print(request.form) + return redirect("/translations") + from . import database database.initialize_app(app) diff --git a/kanken_online/lang.py b/kanken_online/lang.py index 01f5a72..a9a6e9a 100644 --- a/kanken_online/lang.py +++ b/kanken_online/lang.py @@ -21,7 +21,8 @@ EXISTING_STRINGS = { "incorrect_password" "about", "about-para", - "indices" + "indices", + "translations" } ENGLISH = { @@ -52,7 +53,8 @@ ENGLISH = { "dark_theme": "Dark theme", "light_theme": "Light theme", "language": "Language", - "theme": "Color settings" + "theme": "Color settings", + "translations": "Translations", } JAPANESE = { @@ -83,7 +85,8 @@ JAPANESE = { "dark_theme": "ダークモード", "light_theme": "ライトモード", "language": "言語", - "theme": "色設定" + "theme": "色設定", + "translations": "翻訳", } LANGUAGES = { diff --git a/kanken_online/templates/translations.html b/kanken_online/templates/translations.html new file mode 100644 index 0000000..7d205b3 --- /dev/null +++ b/kanken_online/templates/translations.html @@ -0,0 +1,19 @@ +{% extends 'base.html' %} + +{% block header %} +

{% block title %}{{ localize("translations") }}{% endblock %}

+{% endblock %} + +{% block content %} +
+ {% for language, data in strings.items() %} +

{{ language }}

+ {% for string, translation in data.items() %} + + +
+ {% endfor %} + {% endfor %} + +
+{% endblock %} \ No newline at end of file