From bab6fcf227d949ef8e49aa2f13ae813c25aefa37 Mon Sep 17 00:00:00 2001 From: Kiril Kovachev Date: Tue, 15 Oct 2024 19:02:26 +0100 Subject: [PATCH] Add script to add strings using the string editor --- kanken_online/static/translations.js | 28 +++++++++++++++++++++++ kanken_online/templates/translations.html | 24 ++++++++++++------- 2 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 kanken_online/static/translations.js diff --git a/kanken_online/static/translations.js b/kanken_online/static/translations.js new file mode 100644 index 0000000..33e60d6 --- /dev/null +++ b/kanken_online/static/translations.js @@ -0,0 +1,28 @@ +const addStringButton = document.getElementById("add-string-button"); +addStringButton.addEventListener("click", (e) => { + const stringName = prompt("Enter a string name: "); + if (stringName == "") { + return; + } + for (let section of document.getElementsByClassName("translation-section")) { + // const lang = section.getAttribute("data-lang"); + // + // + //
+ const label = document.createElement("label"); + label.setAttribute("for", stringName); + label.innerText = stringName; + + const input = document.createElement("input"); + input.setAttribute("type", "text"); + input.setAttribute("id", stringName); + input.setAttribute("name", stringName); + input.setAttribute("value", ""); + + const br = document.createElement("br"); + + section.appendChild(label); + section.appendChild(input); + section.appendChild(br); + } +}); \ No newline at end of file diff --git a/kanken_online/templates/translations.html b/kanken_online/templates/translations.html index 321ec3c..417f519 100644 --- a/kanken_online/templates/translations.html +++ b/kanken_online/templates/translations.html @@ -1,19 +1,27 @@ {% extends 'base.html' %} +{% block scripts %} + +{% endblock %} + {% 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 %} - +
+

{{ language }}

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