aboutsummaryrefslogtreecommitdiff
path: root/translate.py
diff options
context:
space:
mode:
Diffstat (limited to 'translate.py')
-rw-r--r--translate.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/translate.py b/translate.py
new file mode 100644
index 0000000..c73a364
--- /dev/null
+++ b/translate.py
@@ -0,0 +1,38 @@
+import re
+import sys
+
+lang = sys.argv[1]
+
+trmap = {
+ '_a_browser_version': '<a href="https://hurrycurry-web.metamuffin.org/">',
+ '_a_book': '<a href="https://s.metamuffin.org/static/hurrycurry/book.pdf">',
+ '_a_codeberg': '<a href="https://codeberg.org/hurrycurry/hurrycurry/">',
+ '_a_weblate': '<a href="https://translate.codeberg.org/engage/hurrycurry/">',
+ '_a_end': '</a>',
+ '_b': '<b>',
+ '_b_end': '</b>',
+ '_developers': '<span id="shuffle">nokoe, metamuffin, tpart</span>',
+ '_lang': lang,
+}
+for l in ["en", lang]:
+ for line in open(f"main/locale/{l}.ini"):
+ line = line.strip()
+ if line == "[hurrycurry]": continue
+ if line == "": continue
+ key, value = line.split("=")
+ trmap[key.strip()] = value.strip().replace("<","&lt;").replace(">","&gt;")
+
+s = open("index_template.html").read()
+
+def replace(matches):
+ x = matches.group(1)
+ if x in trmap: x = trmap[x]
+ else: x = f"MISSING TR ({x})"
+ return x
+
+while True:
+ sb = s
+ s = re.sub(r"\{([\w\.]+)\}", replace, s)
+ if s == sb: break
+
+open(f"index.{lang}.html","w+").write(s)