From 9b36fb2c19c0b2c86b8a63f8955dc482d870ff06 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 25 Feb 2024 17:50:33 +0000 Subject: [PATCH] Add package translations page --- app/blueprints/packages/__init__.py | 7 ++- app/blueprints/packages/packages.py | 8 +++ app/templates/packages/translation.html | 81 +++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 app/templates/packages/translation.html diff --git a/app/blueprints/packages/__init__.py b/app/blueprints/packages/__init__.py index 944ee451..aab0512e 100644 --- a/app/blueprints/packages/__init__.py +++ b/app/blueprints/packages/__init__.py @@ -32,6 +32,11 @@ def get_package_tabs(user: User, package: Package): "title": gettext("Edit Details"), "url": package.get_url("packages.create_edit") }, + { + "id": "translation", + "title": gettext("Translation"), + "url": package.get_url("packages.translation") + }, { "id": "releases", "title": gettext("Releases"), @@ -70,7 +75,7 @@ def get_package_tabs(user: User, package: Package): ] if package.type == PackageType.MOD or package.type == PackageType.TXP: - retval.insert(1, { + retval.insert(2, { "id": "game_support", "title": gettext("Supported Games"), "url": package.get_url("packages.game_support") diff --git a/app/blueprints/packages/packages.py b/app/blueprints/packages/packages.py index ab33521b..c07a4422 100644 --- a/app/blueprints/packages/packages.py +++ b/app/blueprints/packages/packages.py @@ -461,6 +461,14 @@ def move_to_state(package): return redirect(package.get_url("packages.view")) +@bp.route("/packages///translation/") +@login_required +@is_package_page +def translation(package): + return render_template("packages/translation.html", package=package, + tabs=get_package_tabs(current_user, package), current_tab="translation") + + @bp.route("/packages///remove/", methods=["GET", "POST"]) @login_required @is_package_page diff --git a/app/templates/packages/translation.html b/app/templates/packages/translation.html new file mode 100644 index 00000000..e21d063e --- /dev/null +++ b/app/templates/packages/translation.html @@ -0,0 +1,81 @@ +{% extends "packages/package_base.html" %} + +{% block title %} +{{ _("Translation") }} +{% endblock %} + +{% block content %} + {% set translations = package.translations.all() %} + {% set num = translations | length + 1 %} + + + {{ _("Help") }} + + +

{{ self.title() }}

+ {% if num == 1 %} +

+ {{ _("To provide translations for your %(type)s, you need to create .tr files and upload a new release.", type=package.type.text | lower) }} + {{ _("For information on how to do this, see the modding book chapter and lua_api.md") }} +

+

+ + {{ _("Translation - Minetest Modding Book") }} + + + {{ _("Translating content meta - lua_api.md") }} + +

+ {% else %} +

+ {{ _("%(title)s is available in %(num)d languages.", title=package.title, num=num) }} + {{ _("ContentDB reads translations from locale files (.tr) in your package.") }} +

+ +
+
+
+
+ {{ _("Language") }} +
+
+ {{ _("Title") }} +
+
+ {{ _("Short Description") }} +
+
+
+ +
+
+
+ English +
+
+ {{ package.title }} +
+
+ {{ package.short_desc }} +
+
+
+ + {% for translation in translations %} +
+
+
+ {{ translation.language.title }} +
+
+ {{ translation.title or "" }} +
+
+ {{ translation.short_desc or "" }} +
+
+
+ {% endfor %} + {% endif %} +
+{% endblock %}