diff --git a/api/app.js b/api/app.js index 9cef51c..a89e8a7 100644 --- a/api/app.js +++ b/api/app.js @@ -12,6 +12,8 @@ app.get("/year-progress", (req, res) => { const startDateParam = req.query.startDate; const endDateParam = req.query.endDate; + const lang = req.query.lang || "en"; + let start = startDateParam ? new Date(startDateParam) : new Date(now.getFullYear(), 0, 1); @@ -29,14 +31,24 @@ app.get("/year-progress", (req, res) => { const progress = ((now - start) / (end - start)) * 100; const progressFormatted = progress.toFixed(6); - const displayText = currentYear; + + + const translations = { + en: `Completed`, + es: `Completado`, + fr: `Terminé`, + de: `Abgeschlossen`, + hi: `पूरा हुआ`, + }; + + const localizedText = `${progressFormatted}% of ${currentYear} ${translations[lang] || translations["en"]}`; const svg = ` - ${progressFormatted}% of ${displayText} Completed + ${localizedText} `; @@ -50,4 +62,9 @@ app.get("/", (req, res) => { res.sendFile(path.join(__dirname, "..", "public", "index.html")); }); +const PORT = 3000; +app.listen(PORT, () => { + console.log(`Server running at http://localhost:${PORT}`); +}); + module.exports = app; diff --git a/package-lock.json b/package-lock.json index ce55770..76bffbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "express": "^4.21.0" + "express": "^4.21.2" } }, "node_modules/accepts": { @@ -104,9 +104,9 @@ } }, "node_modules/cookie": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", - "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", "license": "MIT", "engines": { "node": ">= 0.6" @@ -215,9 +215,9 @@ } }, "node_modules/express": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.0.tgz", - "integrity": "sha512-VqcNGcj/Id5ZT1LZ/cfihi3ttTn+NJmkli2eZADigjq29qTlWi/hAQ43t/VLPq8+UX06FCEx3ByOYet6ZFblng==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", "license": "MIT", "dependencies": { "accepts": "~1.3.8", @@ -225,7 +225,7 @@ "body-parser": "1.20.3", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.6.0", + "cookie": "0.7.1", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -239,7 +239,7 @@ "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.10", + "path-to-regexp": "0.1.12", "proxy-addr": "~2.0.7", "qs": "6.13.0", "range-parser": "~1.2.1", @@ -254,6 +254,10 @@ }, "engines": { "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/finalhandler": { @@ -532,9 +536,9 @@ } }, "node_modules/path-to-regexp": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", - "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==", + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", "license": "MIT" }, "node_modules/proxy-addr": { diff --git a/package.json b/package.json index f3c6071..d71c990 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,6 @@ "author": "", "license": "ISC", "dependencies": { - "express": "^4.21.0" + "express": "^4.21.2" } -} \ No newline at end of file +} diff --git a/public/index.html b/public/index.html index 63265e7..fd789bf 100644 --- a/public/index.html +++ b/public/index.html @@ -29,10 +29,40 @@ -

Year Progress

+

Year Progress

+ +
+ + +
+ + + + Year Progress @@ -106,6 +136,7 @@

integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous" > +