feat: describe current sky in weather hero
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user