From 4d52229e4d769fd6e92e2a54f567d0fa0b7b4d67 Mon Sep 17 00:00:00 2001
From: Yax <1949284+kianby@users.noreply.github.com>
Date: Fri, 31 May 2024 16:54:25 +0200
Subject: [PATCH] Add EN translations
---
.../interface/templates/admin_en.html | 64 +++++++++++++++++++
.../interface/templates/login_en.html | 42 ++++++++++++
src/stacosys/interface/web/admin.py | 30 ++++++---
3 files changed, 126 insertions(+), 10 deletions(-)
create mode 100644 src/stacosys/interface/templates/admin_en.html
create mode 100644 src/stacosys/interface/templates/login_en.html
diff --git a/src/stacosys/interface/templates/admin_en.html b/src/stacosys/interface/templates/admin_en.html
new file mode 100644
index 0000000..59c8f19
--- /dev/null
+++ b/src/stacosys/interface/templates/admin_en.html
@@ -0,0 +1,64 @@
+
+
+
+
+
+Stacosys Comment Moderation
+
+
+
+
+ Comment Moderation
+
+
+
+ {% with messages = get_flashed_messages() %}
+ {% if messages %}
+
+ {% for message in messages %}
+ {{ message }}
+ {% endfor %}
+
+ {% endif %}
+ {% endwith %}
+
+
+
+ Date |
+ Author |
+ Comment |
+ Article |
+ Actions |
+
+
+
+ {% for comment in comments %}
+
+ {{ comment.created }} |
+ {{ comment.author_name }} |
+ {{ comment.content }} |
+ {{ comment.url }} |
+
+
+
+ |
+
+ {% endfor %}
+
+
+
+
+
+
diff --git a/src/stacosys/interface/templates/login_en.html b/src/stacosys/interface/templates/login_en.html
new file mode 100644
index 0000000..6d81754
--- /dev/null
+++ b/src/stacosys/interface/templates/login_en.html
@@ -0,0 +1,42 @@
+
+
+
+
+
+Stacosys
+
+
+
+
+
+ Comment Moderation Login
+
+
+ {% with messages = get_flashed_messages() %}
+ {% if messages %}
+
+ {% for message in messages %}
+ {{ message }}
+ {% endfor %}
+
+ {% endif %}
+ {% endwith %}
+
+
+
+
+
diff --git a/src/stacosys/interface/web/admin.py b/src/stacosys/interface/web/admin.py
index 64aa3da..9e35d50 100644
--- a/src/stacosys/interface/web/admin.py
+++ b/src/stacosys/interface/web/admin.py
@@ -37,8 +37,10 @@ def login():
if is_login_ok(username, password):
session["user"] = username
return redirect("/web/admin")
- # TODO localization
- flash("Identifiant ou mot de passe incorrect")
+ if app.config["CONFIG"].get(ConfigParameter.LANG) == "fr":
+ flash("Identifiant ou mot de passe incorrect")
+ else:
+ flash("Username or password incorrect")
return redirect("/web/login")
# GET
return render_template(
@@ -49,6 +51,10 @@ def login():
@app.route("/web/logout", methods=["GET"])
def logout():
session.pop("user")
+ if app.config["CONFIG"].get(ConfigParameter.LANG) == "fr":
+ flash("Vous avez été déconnecté.")
+ else:
+ flash("You have been logged out.")
return redirect("/web/admin")
@@ -58,8 +64,6 @@ def admin_homepage():
"user" in session
and session["user"] == app.config["CONFIG"].get(ConfigParameter.WEB_USERNAME)
):
- # TODO localization
- flash("Vous avez été déconnecté.")
return redirect("/web/login")
comments = dao.find_not_published_comments()
@@ -74,15 +78,21 @@ def admin_homepage():
def admin_action():
comment = dao.find_comment_by_id(request.form.get("comment"))
if comment is None:
- # TODO localization
- flash("Commentaire introuvable")
+ if app.config["CONFIG"].get(ConfigParameter.LANG) == "fr":
+ flash("Commentaire introuvable")
+ else:
+ flash("Comment not found.")
elif request.form.get("action") == "APPROVE":
dao.publish_comment(comment)
app.config["RSS"].generate()
- # TODO localization
- flash("Commentaire publié")
+ if app.config["CONFIG"].get(ConfigParameter.LANG) == "fr":
+ flash("Commentaire publié")
+ else:
+ flash("Comment published.")
else:
dao.delete_comment(comment)
- # TODO localization
- flash("Commentaire supprimé")
+ if app.config["CONFIG"].get(ConfigParameter.LANG) == "fr":
+ flash("Commentaire supprimé")
+ else:
+ flash("Comment deleted.")
return redirect("/web/admin")