chubin / wttr.in

:partly_sunny: The right way to check the weather
https://wttr.in
Apache License 2.0
24.27k stars 1.09k forks source link

Units are not displayed when using different country-codes #755

Closed the-saddest-clown closed 1 year ago

the-saddest-clown commented 2 years ago

When running curl fr.wttr.in/Paris or curl wttr.in/Paris?lang=fr the output don't show units (Km/h, Km, mm except temperature °C). no_units

However running curl wttr.in/paris shows all the units units

Linux Mint 20.3 "Una" Xfce.

bdejean commented 2 years ago

Hello, it is not specific to curl, same behaviour using Firefox.

the-saddest-clown commented 2 years ago

Obviously not a curl problem yeah. Same when visiting https://wttr.in/Paris on ungoogled-chromium with french as default locale. However forcing english language https://wttr.in/Paris?lang=en display the units correctly, still on ugoogled-chromium. So there is a problem regarding the french translation of wttr.in, at least the way it is supposed to display the units. I looked in the code for something that may be modified but cannot find it otherwise I woul like to help improving it.

vegsplore commented 2 years ago

Similar observation: I don't get any units for wttr.in/hamburg or wttr.in/hamburg?lang=de . Can only see units if I set ?lang=en.

Not a problem - still love it. Just wanted to notify :)

tobi-the-fraggel commented 2 years ago

Can confirm the issue. Units also disappear when using other ways of providing localization. For Example: bash.function recommendation in Spanish: curl -fGsS -H "Accept-Language: es" --data-urlencode 0m --compressed "wttr.in/Barcelona" using country subdomain in German: curl de.wttr.in/Berlin switching to imperial units doesn't matter: curl de.wttr.in/Berlin?0u

I've tested all officially supported locale params according to current output of :help result. Interestingly some countries seem to get units. The accuracy of this test is not 100%, but close enough for an approximate esteem. Result shows every country code followed by units found, if any:

#! /usr/bin/env bash
for country in am ar af be bn ca da de el et fr fa hi hu ia id it lt mg nb nl oc pl pt-br ro ru ta tr th uk vi zh-cn zh-tw;
do 
  echo "Result for ${country}:"
  curl -s ${country}.wttr.in/Berlin?T0 | grep -E "[0-9]{1,2} \w{2}"
done

Result:

Result for am:
Result for ar:
Result for af:
Result for be:
     \_(   ).   ↘ 15 км/г      
     /(___(__)  10 км          
                1.2 мм         
Result for bn:
Result for ca:
Result for da:
Result for de:
Result for el:
Result for et:
Result for fr:
Result for fa:
Result for hi:
Result for hu:
Result for ia:
Result for id:
Result for it:
Result for lt:
Result for mg:
Result for nb:
Result for nl:
Result for oc:
Result for pl:
Result for pt-br:
Result for ro:
Result for ru:
     \_(   ).   ↘ 15 км/ч      
     /(___(__)  10 км          
                1.2 мм         
Result for ta:
Result for tr:
     \_(   ).   ↘ 15 km/sa     
Result for th:
Result for uk:
     \_(   ).   ↘ 15 км/год    
     /(___(__)  10 км          
                1.2 мм         
Result for vi:
Result for zh-cn:
Result for zh-tw:

So only country codes be, ru, tr and uk get at least some unit decorations. All other country codes behave as described by previous reporters. Therefore @the-saddest-clown you may consider to remove "french translation" from issue title. This appears to be a more general bug.

wttr.in is an awesome application and I'd love to see this bug fixed. Sadly I don't see myself capable of contributing to the code base. That's above my skill level, I am afraid to admit.

EDIT: I've also did the test with all "unsupported" country codes and none of them receives unit decorations. Just mentioning it to complete all available country codes. Currently unsupported codes are: az bg bs cy cs eo es eu fi ga hi hr hy is ja jv ka kk ko ky lv mk ml mr nl fy nn pt pt-br sk sl sr sr-lat sv sw te uz zh zu he in case anyone wants to run above for-loop with these.

chubin commented 1 year ago

The problem is fixed now. Please test if it works for you

tobi-the-fraggel commented 1 year ago

@chubin thx mate - that's a lot better. Fixed for all aforementioned country codes.

git-bash users still may have some issues with Arabic characters on a standard English windows installation. That's not an issue of your application though. I am just mentioning it for completion.

chubin commented 1 year ago

I think it depends on the terminal configuration. There are some known problems with RTL scripts indeed. But that's true, the problem is not related to this issue.

Great that the problem with the units is fixed now.