ctucx.git: oeffi-web

[nimlang] oeffisearch fork that works without javascript

commit 1c7ed74a7d3504b88d433f58417ba04ee9e271c1
parent 4c135a61ed43189f5d52bb9f7f574e22980cbd17
Author: Leah Thein <leah@toaster.fritz.box>
Date: Fri, 4 Dec 2020 18:38:30 +0100

fix gcsafe warnings
1 file changed, 23 insertions(+), 18 deletions(-)
M
src/translations.nim
|
41
+++++++++++++++++++++++------------------
diff --git a/src/translations.nim b/src/translations.nim
@@ -1,10 +1,14 @@
 import json
 
-let availableTranslations* = @["en", "de"]
+var availableTranslations* {.threadvar.}: seq[string]
+var translations* {.threadvar.}: JsonNode
 
-let translations* = %* {
-  "global": {
-    "en": {
+proc initTranslations = # for gc-safe
+  availableTranslations = @["en", "de"]
+
+  translations = %* {
+    "global": {
+      "en": {
         "LANG":      "en",
         "FROM":      "From",
         "TO":        "To",

@@ -17,7 +21,7 @@ let translations* = %* {
         "CHANGES":   "Changes"
       },
 
-    "de": {
+      "de": {
         "LANG":      "de",
         "FROM":      "Von",
         "TO":        "Nach",

@@ -31,8 +35,8 @@ let translations* = %* {
       }
     },
 
-  "search": {
-    "en": {
+    "search": {
+      "en": {
         "ISARR":                 "Search by Arrival",
         "DATE":                  "Date (YYYY-MM-DD)",
         "TIME":                  "Time (HH:mm)",

@@ -52,7 +56,7 @@ let translations* = %* {
         "LANGUAGE":              "Language"
       },
 
-    "de": {
+      "de": {
         "ISARR":                 "Ankunftszeit statt Abfahrtszeit",
         "DATE":                  "Datum (im Format YYYY-MM-DD)",
         "TIME":                  "Uhrzeit (im Format HH:mm)",

@@ -71,26 +75,26 @@ let translations* = %* {
         "SEARCH":                "Suchen",
         "LANGUAGE":              "Sprache"
       }
-    }, 
+    },
 
-  "journeys": {
-    "en": {
+    "journeys": {
+      "en": {
         "BACK":                  "Back to search",
         "EARLIER":               "erlier",
         "LATER":                 "later",
         "DETAILS":               "Details"
       },
 
-    "de": {
+      "de": {
         "BACK":                  "Zurück zur Suche",
         "EARLIER":               "früher",
         "LATER":                 "später",
         "DETAILS":               "Details"
       }
-  },
+    },
 
-  "journey": {
-    "en": {
+    "journey": {
+      "en": {
         "BACK":                  "Back to overview",
         "DATE":                  "Date",
         "STATION":               "Station",

@@ -104,7 +108,7 @@ let translations* = %* {
         "RELOAD":                "Refresh"
       },
 
-    "de": {
+      "de": {
         "BACK":                  "Zurück zur Übersicht",
         "DATE":                  "Datum",
         "STATION":               "Station",

@@ -118,4 +122,6 @@ let translations* = %* {
         "RELOAD":                "Datenstand erneuern"
       }
     }
-}-
\ No newline at end of file
+  }
+
+initTranslations()