From 1b1460fd45ae29a1fda2456ce59d7e3fb0d5f2dc Mon Sep 17 00:00:00 2001 From: kyle Date: Sun, 15 Feb 2026 19:51:49 +0100 Subject: [PATCH] feat: translate all user-facing text to Swedish for consistency Co-Authored-By: Claude Opus 4.6 --- public/js/components/DeparturesManager.js | 8 +++---- public/js/components/WeatherManager.js | 29 +++++++++++++++++++---- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/public/js/components/DeparturesManager.js b/public/js/components/DeparturesManager.js index 833b864..408cb37 100644 --- a/public/js/components/DeparturesManager.js +++ b/public/js/components/DeparturesManager.js @@ -119,16 +119,16 @@ class DeparturesManager { if (diffMinutes <= 0) { return 'Nu'; } else if (diffMinutes === 1) { - return 'In 1 minute'; + return 'Om 1 minut'; } else if (diffMinutes < 60) { - return `In ${diffMinutes} minutes`; + return `Om ${diffMinutes} minuter`; } else { const hours = Math.floor(diffMinutes / 60); const minutes = diffMinutes % 60; if (minutes === 0) { - return `In ${hours} hour${hours > 1 ? 's' : ''}`; + return `Om ${hours} timm${hours > 1 ? 'ar' : 'e'}`; } else { - return `In ${hours} hour${hours > 1 ? 's' : ''} and ${minutes} minute${minutes > 1 ? 's' : ''}`; + return `Om ${hours} timm${hours > 1 ? 'ar' : 'e'} och ${minutes} minut${minutes > 1 ? 'er' : ''}`; } } } diff --git a/public/js/components/WeatherManager.js b/public/js/components/WeatherManager.js index 7058da4..2706b04 100644 --- a/public/js/components/WeatherManager.js +++ b/public/js/components/WeatherManager.js @@ -5,6 +5,24 @@ */ class WeatherManager { + static WEATHER_CONDITIONS_SV = { + 'Clear': 'Klart', + 'Clouds': 'Molnigt', + 'Rain': 'Regn', + 'Drizzle': 'Duggregn', + 'Thunderstorm': 'Åska', + 'Snow': 'Snö', + 'Mist': 'Dimma', + 'Fog': 'Dimma', + 'Haze': 'Dis', + 'Smoke': 'Rök', + 'Dust': 'Damm', + 'Sand': 'Sand', + 'Ash': 'Aska', + 'Squall': 'Byar', + 'Tornado': 'Tornado' + }; + constructor(options = {}) { // Default options // Get API key from options, window (injected by server from .env), or fallback @@ -297,7 +315,7 @@ class WeatherManager { const conditionElement = document.querySelector('#custom-weather .weather-icon div'); if (conditionElement) { - conditionElement.textContent = this.weatherData.condition; + conditionElement.textContent = WeatherManager.WEATHER_CONDITIONS_SV[this.weatherData.condition] || this.weatherData.condition; } const iconElement = document.querySelector('#custom-weather .weather-icon img'); @@ -364,7 +382,7 @@ class WeatherManager { if (sunTimesElement && this.sunTimes) { const sunriseTime = this.formatTime(this.sunTimes.today.sunrise); const sunsetTime = this.formatTime(this.sunTimes.today.sunset); - sunTimesElement.textContent = `☀️ Sunrise: ${sunriseTime} | 🌙 Sunset: ${sunsetTime}`; + sunTimesElement.textContent = `☀️ Soluppgång: ${sunriseTime} | 🌙 Solnedgång: ${sunsetTime}`; } // Update daylight hours bar @@ -399,7 +417,8 @@ class WeatherManager { const strong = document.createElement('strong'); strong.textContent = `${this.weatherData.temperature}\u00B0C`; tempSpan.appendChild(strong); - tempSpan.appendChild(document.createTextNode(` ${this.weatherData.condition || ''}`)); + const conditionSv = WeatherManager.WEATHER_CONDITIONS_SV[this.weatherData.condition] || this.weatherData.condition; + tempSpan.appendChild(document.createTextNode(` ${conditionSv || ''}`)); bar.appendChild(tempSpan); const sep1 = document.createElement('span'); @@ -415,7 +434,7 @@ class WeatherManager { } const sunriseSpan = document.createElement('span'); - sunriseSpan.textContent = `\u2600\uFE0F Sunrise ${sunriseStr}`; + sunriseSpan.textContent = `☀️ Sol ↑ ${sunriseStr}`; bar.appendChild(sunriseSpan); const sep2 = document.createElement('span'); @@ -424,7 +443,7 @@ class WeatherManager { bar.appendChild(sep2); const sunsetSpan = document.createElement('span'); - sunsetSpan.textContent = `\uD83C\uDF19 Sunset ${sunsetStr}`; + sunsetSpan.textContent = `🌙 Sol ↓ ${sunsetStr}`; bar.appendChild(sunsetSpan); }