-
+
diff --git a/components/weather/weather-hero.tsx b/components/weather/weather-hero.tsx
index 9542887..f5b81cb 100644
--- a/components/weather/weather-hero.tsx
+++ b/components/weather/weather-hero.tsx
@@ -42,7 +42,7 @@ function readDevWeatherEffectOverride(): DevWeatherEffectOverride | null {
return null;
}
-export function WeatherHero({ station, currentWeather, currentWeatherLoading = false, locationName, distanceKm }: { station: SynopStation; currentWeather?: ImgwCurrentWeather | null; currentWeatherLoading?: boolean; locationName?: string; distanceKm?: number }) {
+export function WeatherHero({ station, currentWeather, currentWeatherLoading = false, currentForecastWeatherCode, locationName, distanceKm }: { station: SynopStation; currentWeather?: ImgwCurrentWeather | null; currentWeatherLoading?: boolean; currentForecastWeatherCode?: number | null; locationName?: string; distanceKm?: number }) {
const { language, t } = useI18n();
const temperatureUnit = useWeatherStore((state) => state.temperatureUnit);
const windSpeedUnit = useWeatherStore((state) => state.windSpeedUnit);
@@ -80,6 +80,7 @@ export function WeatherHero({ station, currentWeather, currentWeatherLoading = f
: devEffectOverride === "rain" || devEffectOverride === "none"
? false
: currentWeather?.condition === "thunderstorm";
+ const weatherDescription = getWeatherDescription(displayedStation, language, currentWeather?.condition, currentForecastWeatherCode);
useEffect(() => {
if (process.env.NODE_ENV !== "development") return;
@@ -102,7 +103,7 @@ export function WeatherHero({ station, currentWeather, currentWeatherLoading = f
{displayedLocationName}
- {getWeatherDescription(displayedStation, language, currentWeather?.condition)}
+ {weatherDescription}
@@ -124,7 +125,7 @@ export function WeatherHero({ station, currentWeather, currentWeatherLoading = f
{formatTemperature(displayedStation.temperature, language, temperatureUnit)}
-
{getWeatherDescription(displayedStation, language, currentWeather?.condition)}
+
{weatherDescription}
{t("weather.feelsLike")} {formatTemperature(feelsLike, language, temperatureUnit)} ยท {t("weather.measurement")} {formatDateTime(displayedStation.measuredAt, language)}
diff --git a/lib/i18n.tsx b/lib/i18n.tsx
index 6aacd2f..645634e 100644
--- a/lib/i18n.tsx
+++ b/lib/i18n.tsx
@@ -133,7 +133,7 @@ const translations = {
"weather.feelsLike": "Odczuwalna",
"weather.measurement": "pomiar",
"weather.windDirection": "Kierunek wiatru",
- "weather.calm": "Spokojne warunki",
+ "weather.calm": "Pogodnie",
"weather.humid": "Wilgotno",
"weather.strongWind": "Silny wiatr",
"weather.currentRain": "Opady deszczu",
@@ -380,7 +380,7 @@ const translations = {
"weather.feelsLike": "Feels like",
"weather.measurement": "measurement",
"weather.windDirection": "Wind direction",
- "weather.calm": "Calm conditions",
+ "weather.calm": "Fair",
"weather.humid": "Humid",
"weather.strongWind": "Strong wind",
"weather.currentRain": "Rain",
diff --git a/lib/weather-utils.ts b/lib/weather-utils.ts
index 0ff6a8d..d6e156e 100644
--- a/lib/weather-utils.ts
+++ b/lib/weather-utils.ts
@@ -237,11 +237,25 @@ export function getWeatherMoodFromData(station: SynopStation, date = new Date())
return "mild";
}
-export function getWeatherDescription(station: SynopStation, language: Language = "pl", condition?: CurrentWeatherCondition) {
+function getForecastConditionDescription(code: number | null, language: Language) {
+ if (code === 0) return translate(language, "forecast.condition.clear");
+ if (code === 1 || code === 2) return translate(language, "forecast.condition.partlyCloudy");
+ if (code === 3) return translate(language, "forecast.condition.cloudy");
+ if (code === 45 || code === 48) return translate(language, "forecast.condition.fog");
+ if (code !== null && code >= 51 && code <= 57) return translate(language, "forecast.condition.drizzle");
+ if (code !== null && ((code >= 61 && code <= 67) || (code >= 80 && code <= 82))) return translate(language, "forecast.condition.rain");
+ if (code !== null && ((code >= 71 && code <= 77) || code === 85 || code === 86)) return translate(language, "forecast.condition.snow");
+ if (code !== null && code >= 95) return translate(language, "forecast.condition.thunderstorm");
+ return null;
+}
+
+export function getWeatherDescription(station: SynopStation, language: Language = "pl", condition?: CurrentWeatherCondition, forecastWeatherCode?: number | null) {
if (condition === "thunderstorm") return translate(language, "weather.thunderstorm");
if (condition === "snow") return translate(language, "weather.currentSnow");
if (condition === "rain") return translate(language, "weather.currentRain");
if ((station.windSpeed ?? 0) >= 8) return translate(language, "weather.strongWind");
+ const forecastDescription = getForecastConditionDescription(forecastWeatherCode ?? null, language);
+ if (forecastDescription) return forecastDescription;
if ((station.humidity ?? 0) >= 90) return translate(language, "weather.humid");
return translate(language, "weather.calm");
}