Skip to content

Commit

Permalink
fix(translations): Fixed a problem related to the feels like translat…
Browse files Browse the repository at this point in the history
…ions and refactored the code for the logic of the feels like phrases
  • Loading branch information
FleetAdmiralJakob committed Jan 17, 2024
1 parent 5ae17ac commit 239c758
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 33 deletions.
2 changes: 1 addition & 1 deletion apps/web/public/locales/de/home.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"feels like phrase slightly warm": "Perfekte Temeperatur für ein Picknick!",
"feels like phrase neutral": "Perfektes Wetter für einen Spaziergang!",
"feels like phrase slightly cold": "Eine leichte Jacke könnte erforderlich sein.",
"feels like phrase slightly moor cold": "Es ist ein eisiger Tag!",
"feels like phrase slightly more cold": "Es ist ein eisiger Tag!",
"feels like phrase cold": "Sogar Pinguine bestellen sich eine heiße Schokolade!",
"feels like phrase very cold": "Auch die Schneemänner frieren!",
"feels like phrase extremely cold": "Es ist so kalt, dass sogar die Eisbären im Haus bleiben!",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/public/locales/en/home.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"feels like phrase slightly warm": "A perfect day for a picnic!",
"feels like phrase neutral": "Just the right temperature, not too hot, not too cold.",
"feels like phrase slightly cold": "A light jacket might be needed.",
"feels like phrase slightly moor cold": "It's a frosty day!",
"feels like phrase slightly more cold": "It's a frosty day!",
"feels like phrase cold": "Penguins are ordering hot chocolate due to the chill!",
"feels like phrase very cold": "Today's frosty weather is making even snowmen shiver!",
"feels like phrase extremely cold": "It's so cold, even the polar bears are staying inside!",
Expand Down
48 changes: 17 additions & 31 deletions apps/web/src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ const Map = dynamic(() => import("@weatherio/ui/map"), { ssr: false });
dayjs.extend(utc);
dayjs.extend(timezone);

function getFeelsLikePhrase(feels_like: number) {
if (feels_like > 320) return "feels like phrase extremely warm";
if (feels_like > 315) return "feels like phrase very warm";
if (feels_like > 305) return "feels like phrase warm";
if (feels_like > 300) return "feels like phrase slightly more warm";
if (feels_like > 295) return "feels like phrase slightly warm";
if (feels_like > 285) return "feels like phrase neutral";
if (feels_like > 279) return "feels like phrase slightly cold";
if (feels_like > 270) return "feels like phrase slightly more cold";
if (feels_like > 264) return "feels like phrase cold";
if (feels_like > 255) return "feels like phrase very cold";
return "feels like phrase extremely cold";
}

function convertWindSpeed(
speedInMetersPerSecond: number,
unit: WindSpeedUnitType,
Expand Down Expand Up @@ -795,37 +809,9 @@ const InternalHome = observer(() => {
)}°F`}
</div>
<div className="text-sm font-medium text-gray-700">
{weatherData.data.feels_like > 320
? translationHome("feels like phrase extremely warm")
: weatherData.data.feels_like > 315
? translationHome("feels like phrase very warm")
: weatherData.data.feels_like > 305
? translationHome("feels like phrase warm")
: weatherData.data.feels_like > 300
? translationHome(
"feels like phrase slightly more warm",
)
: weatherData.data.feels_like > 295
? translationHome("feels like phrase slightly warm")
: weatherData.data.feels_like > 285
? translationHome("feels like phrase neutral")
: weatherData.data.feels_like > 279
? translationHome(
"feels like phrase slightly cold",
)
: weatherData.data.feels_like > 270
? translationHome(
"feels like phrase slightly more cold",
)
: weatherData.data.feels_like > 264
? translationHome("feels like phrase cold")
: weatherData.data.feels_like > 255
? translationHome(
"feels like phrase very cold",
)
: translationHome(
"feels like phrase extremely cold",
)}
{translationHome(
getFeelsLikePhrase(weatherData.data.feels_like),
)}
</div>
</div>
</div>
Expand Down

1 comment on commit 239c758

@vercel
Copy link

@vercel vercel bot commented on 239c758 Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.