Begin translation subsystem page

This commit is contained in:
Kiril Kovachev 2024-10-15 16:52:22 +01:00
parent a5c36e4f0b
commit 9cbf356444
3 changed files with 40 additions and 3 deletions

View File

@ -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)

View File

@ -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 = {

View File

@ -0,0 +1,19 @@
{% extends 'base.html' %}
{% block header %}
<h1>{% block title %}{{ localize("translations") }}{% endblock %}</h1>
{% endblock %}
{% block content %}
<form method="post">
{% for language, data in strings.items() %}
<h2>{{ language }}</h2>
{% for string, translation in data.items() %}
<label for="{{ string }}">{{ string }}</label>
<input type="text" id="{{ string }}" value="{{ translation }}">
<br>
{% endfor %}
{% endfor %}
<button type="submit">Submit</button>
</form>
{% endblock %}