feat: translate all user-facing text to Swedish for consistency

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 19:51:49 +01:00
parent 2b7fc6b016
commit 1b1460fd45
2 changed files with 28 additions and 9 deletions

View File

@@ -119,16 +119,16 @@ class DeparturesManager {
if (diffMinutes <= 0) { if (diffMinutes <= 0) {
return 'Nu'; return 'Nu';
} else if (diffMinutes === 1) { } else if (diffMinutes === 1) {
return 'In 1 minute'; return 'Om 1 minut';
} else if (diffMinutes < 60) { } else if (diffMinutes < 60) {
return `In ${diffMinutes} minutes`; return `Om ${diffMinutes} minuter`;
} else { } else {
const hours = Math.floor(diffMinutes / 60); const hours = Math.floor(diffMinutes / 60);
const minutes = diffMinutes % 60; const minutes = diffMinutes % 60;
if (minutes === 0) { if (minutes === 0) {
return `In ${hours} hour${hours > 1 ? 's' : ''}`; return `Om ${hours} timm${hours > 1 ? 'ar' : 'e'}`;
} else { } 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' : ''}`;
} }
} }
} }

View File

@@ -5,6 +5,24 @@
*/ */
class WeatherManager { 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 = {}) { constructor(options = {}) {
// Default options // Default options
// Get API key from options, window (injected by server from .env), or fallback // 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'); const conditionElement = document.querySelector('#custom-weather .weather-icon div');
if (conditionElement) { 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'); const iconElement = document.querySelector('#custom-weather .weather-icon img');
@@ -364,7 +382,7 @@ class WeatherManager {
if (sunTimesElement && this.sunTimes) { if (sunTimesElement && this.sunTimes) {
const sunriseTime = this.formatTime(this.sunTimes.today.sunrise); const sunriseTime = this.formatTime(this.sunTimes.today.sunrise);
const sunsetTime = this.formatTime(this.sunTimes.today.sunset); 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 // Update daylight hours bar
@@ -399,7 +417,8 @@ class WeatherManager {
const strong = document.createElement('strong'); const strong = document.createElement('strong');
strong.textContent = `${this.weatherData.temperature}\u00B0C`; strong.textContent = `${this.weatherData.temperature}\u00B0C`;
tempSpan.appendChild(strong); 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); bar.appendChild(tempSpan);
const sep1 = document.createElement('span'); const sep1 = document.createElement('span');
@@ -415,7 +434,7 @@ class WeatherManager {
} }
const sunriseSpan = document.createElement('span'); const sunriseSpan = document.createElement('span');
sunriseSpan.textContent = `\u2600\uFE0F Sunrise ${sunriseStr}`; sunriseSpan.textContent = `☀️ Sol ↑ ${sunriseStr}`;
bar.appendChild(sunriseSpan); bar.appendChild(sunriseSpan);
const sep2 = document.createElement('span'); const sep2 = document.createElement('span');
@@ -424,7 +443,7 @@ class WeatherManager {
bar.appendChild(sep2); bar.appendChild(sep2);
const sunsetSpan = document.createElement('span'); const sunsetSpan = document.createElement('span');
sunsetSpan.textContent = `\uD83C\uDF19 Sunset ${sunsetStr}`; sunsetSpan.textContent = `🌙 Sol ↓ ${sunsetStr}`;
bar.appendChild(sunsetSpan); bar.appendChild(sunsetSpan);
} }