More language support

This commit is contained in:
Sören Oesterwind 2022-05-10 21:49:08 +02:00
parent 0b3df97975
commit b790c6ff80
6 changed files with 172 additions and 38 deletions

View File

@ -62,7 +62,6 @@ currentState.textColors = currentState.colorSegments
loggy.log("Reading language file", "info", "Language") loggy.log("Reading language file", "info", "Language")
const languageProfile = JSON.parse(fs.readFileSync("lang/en_uk.json", "utf8")); const languageProfile = JSON.parse(fs.readFileSync("lang/en_uk.json", "utf8"));
loggy.log("Preparing websocket", "info", "Websocket"); loggy.log("Preparing websocket", "info", "Websocket");
const wsServer = new ws.Server({ noServer: true }); const wsServer = new ws.Server({ noServer: true });
wsServer.on('connection', socket => { wsServer.on('connection', socket => {
@ -93,11 +92,15 @@ function updatedData() {
loggy.log("Preparing routes", "info", "Server"); loggy.log("Preparing routes", "info", "Server");
app.get("/", function (req, res) { app.get("/", function (req, res) {
const data = fs.readFileSync("templates/newAdminPanel.html", "utf8"); const data = fs.readFileSync("templates/newAdminPanel.html", "utf8");
try {
res.send( res.send(
Eta.render(data, { Eta.render(data, {
lang: languageProfile lang: languageProfile
})); }));
} catch (e) {
const data = fs.readFileSync("templates/brokenTranslation.html", "utf8");
res.send(data);
}
}); });
app.get("/timer", function (req, res) { app.get("/timer", function (req, res) {
@ -308,7 +311,7 @@ app.get("/api/v1/storage/delete", function (req, res) {
updatedData() updatedData()
}); });
app.use(function(req, res, next) { app.use(function (req, res, next) {
res.status(404); res.status(404);
loggy.log("Server responded with 404 error", "warn", "Server", true); 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); console.error(err.stack);
if(String(err.stack).includes("TypeError: Cannot read properties of undefined")) { if(String(err.stack).includes("TypeError: Cannot read properties of undefined")) {
const data = fs.readFileSync("templates/brokenTranslation.html", "utf8"); 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!'); res.status(500).send('Something broke!');
} }
}); });*/
loggy.log("Starting server", "info", "Server"); loggy.log("Starting server", "info", "Server");
const port = 3005;
const port = 3006
process.on('SIGINT', function () { process.on('SIGINT', function () {
loggy.log("Caught interrupt signal and shutting down gracefully", "info", "Shutdown"); loggy.log("Caught interrupt signal and shutting down gracefully", "info", "Shutdown");
server.close(); // Make the express server stop server.close(); // Make the express server stop
loggy.log("Goodbye! 👋", "magic", "Shutdown", true) loggy.log("Goodbye! 👋", "magic", "Shutdown", true)
loggy.close() loggy.close(); // Close and write log
process.exit(); // Quit the application process.exit(); // Quit the application
}); });
const server = app.listen(port); const server = app.listen(port);

View File

@ -4,7 +4,9 @@
"preview": "Vorschau", "preview": "Vorschau",
"mode": "Modus", "mode": "Modus",
"messaging": "Nachrichten", "messaging": "Nachrichten",
"countdownToTime": "Auf Uhrzeit runterzählen" "countdownToTime": "Auf Uhrzeit runterzählen",
"attention": "Achtung",
"hostinfo": "Host Informationen"
}, },
"sidebar": { "sidebar": {
"home": "Startseite", "home": "Startseite",
@ -16,7 +18,10 @@
{ {
"previewHint": "Eine Vorschau der Timeransicht.", "previewHint": "Eine Vorschau der Timeransicht.",
"modeHint": "", "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": { "placeholders": {
"msgHere": "Message here" "msgHere": "Message here"
@ -27,5 +32,38 @@
"clock": "Uhr", "clock": "Uhr",
"black": "Schwarz", "black": "Schwarz",
"test": "Testbild" "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"]
} }
} }

View File

@ -4,7 +4,9 @@
"preview": "Preview", "preview": "Preview",
"mode": "Mode", "mode": "Mode",
"messaging": "Messaging", "messaging": "Messaging",
"countdownToTime": "Countdown to time" "countdownToTime": "Countdown to time",
"attention": "Attention",
"hostinfo": "Host information"
}, },
"sidebar": { "sidebar": {
"home": "Home", "home": "Home",
@ -16,7 +18,10 @@
{ {
"previewHint": "A preview of what is currently visible on the countdown view", "previewHint": "A preview of what is currently visible on the countdown view",
"modeHint": "", "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": { "placeholders": {
"msgHere": "Message here" "msgHere": "Message here"
@ -36,7 +41,25 @@
"progbarColors": "Progressbar Colors", "progbarColors": "Progressbar Colors",
"time": "Time", "time": "Time",
"color": "Color", "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": { "_metadata": {
"lang": "en", "lang": "en",

70
lang/proto_black.json Normal file
View File

@ -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. █"
}
}

View File

@ -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"}] [{"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"}]

View File

@ -119,14 +119,14 @@
</span> </span>
<div class="ms-auto"> <div class="ms-auto">
<span class="helperTip" data-placement="right" <span class="helperTip" data-placement="right"
title="Copies the link to the timer view" data-toggle="tooltip"> title="<%= it.lang.hints.copyHint %>" data-toggle="tooltip">
<button class="btn" onclick="navigator.clipboard.writeText(window.location.toString() + 'timer')"> <button class="btn" onclick="navigator.clipboard.writeText(window.location.toString() + 'timer')">
<i class="bi bi-clipboard"></i> <i class="bi bi-clipboard"></i>
</button> </button>
</span> </span>
<span class="helperTip" data-placement="right" <span class="helperTip" data-placement="right"
title="Open the countdown view in a new tab" data-toggle="tooltip"> title="<%= it.lang.hints.openInNewTab %>" data-toggle="tooltip">
<a href="/timer" class="btn " target="_blank"><i <a href="/timer" class="btn " target="_blank"><i
class="bi bi-box-arrow-up-right"></i></a> class="bi bi-box-arrow-up-right"></i></a>
</span> </span>
@ -137,7 +137,7 @@
</div> </div>
<div class="col"> <div class="col">
<h3><%= it.lang.titles.mode %> <span class="helperTip" data-placement="right" <h3><%= it.lang.titles.mode %> <span class="helperTip" data-placement="right"
title="Select what to show on the countdown view" data-toggle="tooltip"> title=<%= it.lang.hints.selectMode %> data-toggle="tooltip">
<i class="bi bi-question-circle-fill"></i> <i class="bi bi-question-circle-fill"></i>
</span></h3> </span></h3>
<div class="btn-group" role="group" aria-label="Basic radio toggle button group"> <div class="btn-group" role="group" aria-label="Basic radio toggle button group">
@ -201,7 +201,7 @@
</div> </div>
</div> </div>
<br><br><br> <br><br><br>
<h3><%= it.lang.titles.timer %></h3> <h3><%= it.lang.others.timer %></h3>
<div class="container"> <div class="container">
@ -278,10 +278,10 @@
</p> </p>
</details> </details>
<hr> <hr>
<label for="textColors">Enable Text Colors:</label> <label for="textColors"><%= it.lang.labels.enableTextClrs %></label>
<input type="checkbox" name="textColors" id="textColors"><br> <input type="checkbox" name="textColors" id="textColors"><br>
<details> <details>
<summary>Text Colors</summary> <summary><%= it.lang.labels.textClrs %></summary>
<p> <p>
<div id="table2" class="table-editable"> <div id="table2" class="table-editable">
@ -299,7 +299,7 @@
<button type="button" class="btn btn-outline-success" id="copyColors">Copy from progressbar <button type="button" class="btn btn-outline-success" id="copyColors">Copy from progressbar
colors</button> colors</button>
<button type="button" class="btn btn-outline-success" id="addRow2">Add row</button> <button type="button" class="btn btn-outline-success" id="addRow2"><%= it.lang.labels.row %></button>
</p> </p>
</details> </details>
<br> <br>
@ -316,13 +316,12 @@
<page id="debug" class="pageC hidden flex-fill overflow-auto"> <page id="debug" class="pageC hidden flex-fill overflow-auto">
<h1>Debug page</h1> <h1>Debug page</h1>
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
<h4 class="alert-heading">Attention</h4> <h4 class="alert-heading"><%= it.lang.titles.attention %></h4>
<p>This is a debug page which should only be used by professionals. Changing any options below might <p><%= it.lang.informationTexts.debugInfo %></p>
impact operation.</p>
<hr> <hr>
<p class="mb-0"><b>Proceed with caution.</b></p> <p class="mb-0"><b><%= it.lang.informationTexts.proceedCaution %></b></p>
</div> </div>
<label for="debugMode">Enable time variance display:</label> <label for="debugMode"><%= it.lang.labels.timeVar %></label>
<input type="checkbox" name="debugMode" id="debugModeEnable" value="true"><br><br> <input type="checkbox" name="debugMode" id="debugModeEnable" value="true"><br><br>
<button type="button" class="btn btn-outline-success" id="applyDebug">Apply settings</button> <button type="button" class="btn btn-outline-success" id="applyDebug">Apply settings</button>
@ -330,7 +329,7 @@
<hr> <hr>
<br> <br>
<h3>Host information</h3> <h3><%= it.lang.titles.hostinfo %></h3>
<code id="systemInfo" class="overflow-auto"> <code id="systemInfo" class="overflow-auto">
</code> </code>
@ -345,9 +344,9 @@
<table class="table table-bordered table-responsive-md table-striped text-center" id="colors1"> <table class="table table-bordered table-responsive-md table-striped text-center" id="colors1">
<thead> <thead>
<tr> <tr>
<th class="text-center">Time</th> <th class="text-center"><%= it.lang.labels.time %></th>
<th class="text-center">Color</th> <th class="text-center"><%= it.lang.labels.color %></th>
<th class="text-center">Remove</th> <th class="text-center"><%= it.lang.labels.remove %></th>
</tr> </tr>
</thead> </thead>
<tr id="tableCopySource"> <tr id="tableCopySource">
@ -409,7 +408,10 @@
<h1>About</h1> <h1>About</h1>
Version: <b id="nodeSwVers"></b><br> Version: <b id="nodeSwVers"></b><br>
NodeJS Version: <b id="nodejsVers"></b><br> NodeJS Version: <b id="nodejsVers"></b><br>
<h2>About the translation</h2>
Author: <%= it.lang._metadata.authors %><br>
Language: <%= it.lang._metadata.lang %><br>
Version: <%= it.lang._metadata.version %><br>
</page> </page>
</pages> </pages>
</main> </main>