Add script to add strings using the string editor
This commit is contained in:
parent
bc23f2d1b8
commit
bab6fcf227
28
kanken_online/static/translations.js
Normal file
28
kanken_online/static/translations.js
Normal file
@ -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");
|
||||||
|
// <label for="{{ string }}">{{ string }}</label>
|
||||||
|
// <input type="text" id="{{ string }}" name="{{ string }}" value="{{ translation }}">
|
||||||
|
// <br>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
});
|
@ -1,19 +1,27 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script src="/static/translations.js" defer></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
<h1>{% block title %}{{ localize("translations") }}{% endblock %}</h1>
|
<h1>{% block title %}{{ localize("translations") }}{% endblock %}</h1>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<button id="add-string-button">Add string</button>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
{% for language, data in strings.items() %}
|
{% for language, data in strings.items() %}
|
||||||
|
<div id="{{language}}-translation-section" class="translation-section" lang="{{language}}">
|
||||||
<h2>{{ language }}</h2>
|
<h2>{{ language }}</h2>
|
||||||
{% for string, translation in data.items() %}
|
{% for string, translation in data.items() %}
|
||||||
<label for="{{ string }}">{{ string }}</label>
|
<label lang="en" for="{{ string }}">{{ string }}</label>
|
||||||
<input type="text" id="{{ string }}" name="{{ string }}" value="{{ translation }}">
|
<input type="text" id="{{ string }}" name="{{ string }}" value="{{ translation }}">
|
||||||
<br>
|
<br>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<button type="submit">Submit</button>
|
<button type="submit">Submit</button>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user