From b790c6ff80f08f936c296c4169da0d8e1a704470 Mon Sep 17 00:00:00 2001 From: grey Date: Tue, 10 May 2022 21:49:08 +0200 Subject: [PATCH] More language support --- index.js | 31 ++++++++-------- lang/de_de.json | 42 ++++++++++++++++++++-- lang/en_uk.json | 29 +++++++++++++-- lang/proto_black.json | 70 ++++++++++++++++++++++++++++++++++++ log-journal.json | 2 +- templates/newAdminPanel.html | 36 ++++++++++--------- 6 files changed, 172 insertions(+), 38 deletions(-) create mode 100644 lang/proto_black.json diff --git a/index.js b/index.js index 1d6e761..405fc7c 100644 --- a/index.js +++ b/index.js @@ -62,7 +62,6 @@ currentState.textColors = currentState.colorSegments loggy.log("Reading language file", "info", "Language") const languageProfile = JSON.parse(fs.readFileSync("lang/en_uk.json", "utf8")); - loggy.log("Preparing websocket", "info", "Websocket"); const wsServer = new ws.Server({ noServer: true }); wsServer.on('connection', socket => { @@ -93,11 +92,15 @@ function updatedData() { loggy.log("Preparing routes", "info", "Server"); app.get("/", function (req, res) { const data = fs.readFileSync("templates/newAdminPanel.html", "utf8"); - - res.send( - Eta.render(data, { - lang: languageProfile - })); + try { + res.send( + Eta.render(data, { + lang: languageProfile + })); + } catch (e) { + const data = fs.readFileSync("templates/brokenTranslation.html", "utf8"); + res.send(data); + } }); app.get("/timer", function (req, res) { @@ -308,7 +311,7 @@ app.get("/api/v1/storage/delete", function (req, res) { updatedData() }); -app.use(function(req, res, next) { +app.use(function (req, res, next) { res.status(404); loggy.log("Server responded with 404 error", "warn", "Server", true); @@ -332,7 +335,7 @@ app.use(function(req, res, next) { -app.use(function(err, req, res, next) { +/*app.use(function(err, req, res, next) { console.error(err.stack); if(String(err.stack).includes("TypeError: Cannot read properties of undefined")) { const data = fs.readFileSync("templates/brokenTranslation.html", "utf8"); @@ -341,22 +344,20 @@ app.use(function(err, req, res, next) { res.status(500).send('Something broke!'); } -}); +});*/ loggy.log("Starting server", "info", "Server"); - -const port = 3006 +const port = 3005; process.on('SIGINT', function () { loggy.log("Caught interrupt signal and shutting down gracefully", "info", "Shutdown"); server.close(); // Make the express server stop - loggy.log("Goodbye! πŸ‘‹", "magic", "Shutdown", true) - loggy.close() - process.exit(); // Quit the application - + loggy.log("Goodbye! πŸ‘‹", "magic", "Shutdown", true) + loggy.close(); // Close and write log + process.exit(); // Quit the application }); const server = app.listen(port); diff --git a/lang/de_de.json b/lang/de_de.json index 438bd04..cef756f 100644 --- a/lang/de_de.json +++ b/lang/de_de.json @@ -4,7 +4,9 @@ "preview": "Vorschau", "mode": "Modus", "messaging": "Nachrichten", - "countdownToTime": "Auf Uhrzeit runterzΓ€hlen" + "countdownToTime": "Auf Uhrzeit runterzΓ€hlen", + "attention": "Achtung", + "hostinfo": "Host Informationen" }, "sidebar": { "home": "Startseite", @@ -16,7 +18,10 @@ { "previewHint": "Eine Vorschau der Timeransicht.", "modeHint": "", - "messagingHint": "Zeigt eine Nachricht auf der Timeransicht an." + "messagingHint": "Zeigt eine Nachricht auf der Timeransicht an.", + "copyHint": "Kopiert den Link zu der Countdown-Seite.", + "openInNewTab": "Γ–ffnet den Link in einem neuen Tab.", + "selectMode": "WΓ€hlt einen Modus fΓΌr die Timeransicht.", }, "placeholders": { "msgHere": "Message here" @@ -27,5 +32,38 @@ "clock": "Uhr", "black": "Schwarz", "test": "Testbild" + }, + "labels": + { + "clockOnTimer": "Zeigt die Uhrzeit auf dem Timer:", + "showMillis": "Zeigt Millisekunden auf dem Timer:", + "showProgress": "Zeige Fortschrittsbalken:", + "progbarColors": "Fortschrittsbalken Farben", + "time": "Zeit", + "color": "Farbe", + "remove": "Entfernen", + "enableTextClrs": "Text Farben aktivieren:", + "textClrs": "Text Farben", + "addRow": "Neue Zeile", + "timeVar": "Aktiviere zeitabweichungs display:" + }, + "untis": + { + "seconds": "Sekunden", + "minutes": "Minutes", + "hours": "Stunden", + "days": "Tage", + "weeks": "Wochen", + "months": "Monate", + "years": "Jahre" + }, + "informationTexts": { + "debugInfo": "Das hier ist eine debug seite welche nur von professionellen Personen verwendet werden sollte. ", + "proceedCaution": "Gehen Sie vorsichtig vor" + }, + "_metadata": { + "lang": "de", + "version": "1.0.0", + "authors": ["TheGreydiamond"] } } \ No newline at end of file diff --git a/lang/en_uk.json b/lang/en_uk.json index 32859c1..31e4d53 100644 --- a/lang/en_uk.json +++ b/lang/en_uk.json @@ -4,7 +4,9 @@ "preview": "Preview", "mode": "Mode", "messaging": "Messaging", - "countdownToTime": "Countdown to time" + "countdownToTime": "Countdown to time", + "attention": "Attention", + "hostinfo": "Host information" }, "sidebar": { "home": "Home", @@ -16,7 +18,10 @@ { "previewHint": "A preview of what is currently visible on the countdown view", "modeHint": "", - "messagingHint": "Shows a given message on the timer view" + "messagingHint": "Shows a given message on the timer view", + "copyHint": "Copies the link to the timer view", + "openInNewTab": "Open the countdown view in a new tab", + "selectMode": "Select what to show on the countdown view" }, "placeholders": { "msgHere": "Message here" @@ -36,7 +41,25 @@ "progbarColors": "Progressbar Colors", "time": "Time", "color": "Color", - "remove": "Remove" + "remove": "Remove", + "enableTextClrs": "Enable Text Colours:", + "textClrs": "Text Colours", + "addRow": "Add Row", + "timeVar": "Enable time variance display:" + }, + "untis": + { + "seconds": "Seconds", + "minutes": "Minutes", + "hours": "Hours", + "days": "Days", + "weeks": "Weeks", + "months": "Months", + "years": "Years" + }, + "informationTexts": { + "debugInfo": "This is a debug page which should only be used by professionals. Changing any options below might impact operation.", + "proceedCaution": "Proceed with caution." }, "_metadata": { "lang": "en", diff --git a/lang/proto_black.json b/lang/proto_black.json new file mode 100644 index 0000000..d111cde --- /dev/null +++ b/lang/proto_black.json @@ -0,0 +1,70 @@ +{ + "titles": { + "home": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ", + "preview": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ", + "mode": "β–ˆβ–ˆβ–ˆβ–ˆ", + "messaging": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ", + "countdownToTime": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ", + "attention": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ", + "hostinfo": "β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ" + }, + "sidebar": { + "home": "β–ˆβ–ˆβ–ˆβ–ˆ", + "settings": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ", + "debug": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ", + "about": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ" + }, + "hints": + { + "previewHint": "β–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ", + "modeHint": "", + "messagingHint": "β–ˆβ–ˆβ–ˆβ–ˆ β–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ", + "copyHint": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ", + "openInNewTab": "β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆ β–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ", + "selectMode": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ" + }, + "placeholders": { + "msgHere": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ" + }, + "others": + { + "timer": "β–ˆβ–ˆβ–ˆβ–ˆ", + "clock": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ", + "black": "β–ˆβ–ˆβ–ˆβ–ˆ", + "test": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ" + }, + "labels": + { + "clockOnTimer": "β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ:", + "showMillis": "β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ:", + "showProgress": "β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ:", + "progbarColors": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ", + "time": "β–ˆβ–ˆβ–ˆβ–ˆ", + "color": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ", + "remove": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ", + "enableTextClrs": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ:", + "textClrs": "β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ", + "addRow": "β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ", + "timeVar": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ:" + }, + "untis": + { + "seconds": "Seconds", + "minutes": "Minutes", + "hours": "Hours", + "days": "Days", + "weeks": "Weeks", + "months": "Months", + "years": "Years" + }, + "informationTexts": { + "debugInfo": "β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ. β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ.", + "proceedCaution": "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ." + }, + "_metadata": { + "lang": "none", + "version": "1.0.0", + "authors": ["TheGreydiamond"], + "comment": "A test language without proper text and only black blocks. β–ˆ" + } +} \ No newline at end of file diff --git a/log-journal.json b/log-journal.json index d5410ac..7ce5ed6 100644 --- a/log-journal.json +++ b/log-journal.json @@ -1 +1 @@ -[{"timestamp":"2022-04-06 20:17:16.831","level":"info","module":"Logging","message":"2022-04-06 20:17:16.831 [info] [Logging] Logging initialized"},{"timestamp":"2022-04-06 20:17:16.833","level":"info","module":"Server","message":"2022-04-06 20:17:16.833 [info] [Server] Preparing server"},{"timestamp":"2022-04-06 20:17:16.834","level":"info","module":"Server","message":"2022-04-06 20:17:16.834 [info] [Server] Preparing static routes"},{"timestamp":"2022-04-06 20:17:16.836","level":"info","module":"Server","message":"2022-04-06 20:17:16.836 [info] [Server] Preparing middlewares"},{"timestamp":"2022-04-06 20:17:16.837","level":"info","module":"Config","message":"2022-04-06 20:17:16.837 [info] [Config] Loading config"},{"timestamp":"2022-04-06 20:17:16.838","level":"info","module":"Language","message":"2022-04-06 20:17:16.838 [info] [Language] Reading language file"},{"timestamp":"2022-04-06 20:17:16.838","level":"info","module":"Websocket","message":"2022-04-06 20:17:16.838 [info] [Websocket] Preparing websocket"},{"timestamp":"2022-04-06 20:17:16.839","level":"info","module":"Server","message":"2022-04-06 20:17:16.839 [info] [Server] Preparing routes"},{"timestamp":"2022-04-06 20:17:16.840","level":"info","module":"Server","message":"2022-04-06 20:17:16.840 [info] [Server] Starting server"},{"timestamp":"2022-04-06 20:17:22.971","level":"info","module":"Shutdown","message":"2022-04-06 20:17:22.971 [info] [Shutdown] Caught interrupt signal and shutting down gracefully"}] \ No newline at end of file +[{"timestamp":"2022-05-10 19:38:52.853","level":"info","module":"Logging","message":"2022-05-10 19:38:52.853 [info] [Logging] Logging initialized"},{"timestamp":"2022-05-10 19:38:52.854","level":"info","module":"Server","message":"2022-05-10 19:38:52.854 [info] [Server] Preparing server"},{"timestamp":"2022-05-10 19:38:52.856","level":"info","module":"Server","message":"2022-05-10 19:38:52.856 [info] [Server] Preparing static routes"},{"timestamp":"2022-05-10 19:38:52.857","level":"info","module":"Server","message":"2022-05-10 19:38:52.857 [info] [Server] Preparing middlewares"},{"timestamp":"2022-05-10 19:38:52.857","level":"info","module":"Config","message":"2022-05-10 19:38:52.857 [info] [Config] Loading config"},{"timestamp":"2022-05-10 19:38:52.857","level":"info","module":"Language","message":"2022-05-10 19:38:52.857 [info] [Language] Reading language file"},{"timestamp":"2022-05-10 19:38:52.858","level":"info","module":"Websocket","message":"2022-05-10 19:38:52.858 [info] [Websocket] Preparing websocket"},{"timestamp":"2022-05-10 19:38:52.858","level":"info","module":"Server","message":"2022-05-10 19:38:52.858 [info] [Server] Preparing routes"},{"timestamp":"2022-05-10 19:38:52.859","level":"info","module":"Server","message":"2022-05-10 19:38:52.859 [info] [Server] Starting server"},{"timestamp":"2022-05-10 19:48:56.465","level":"info","module":"Shutdown","message":"2022-05-10 19:48:56.465 [info] [Shutdown] Caught interrupt signal and shutting down gracefully"}] \ No newline at end of file diff --git a/templates/newAdminPanel.html b/templates/newAdminPanel.html index d3c0346..38e331b 100644 --- a/templates/newAdminPanel.html +++ b/templates/newAdminPanel.html @@ -119,14 +119,14 @@
+ title="<%= it.lang.hints.copyHint %>" data-toggle="tooltip"> + title="<%= it.lang.hints.openInNewTab %>" data-toggle="tooltip"> @@ -137,7 +137,7 @@

<%= it.lang.titles.mode %> + title=<%= it.lang.hints.selectMode %> data-toggle="tooltip">

@@ -201,7 +201,7 @@



-

<%= it.lang.titles.timer %>

+

<%= it.lang.others.timer %>

@@ -278,10 +278,10 @@


- +
- Text Colors + <%= it.lang.labels.textClrs %>

@@ -299,7 +299,7 @@ - +


@@ -316,13 +316,12 @@