csparpa / pyowm

A Python wrapper around the OpenWeatherMap web API
https://pyowm.readthedocs.io
MIT License
789 stars 171 forks source link

Language can not be set as described in docs #375

Closed padmalcom closed 3 years ago

padmalcom commented 3 years ago

Hi, thanks for your great library. I tried to set the language to German, so that status is "Regen" instead of "Rain". But following your description (https://pyowm.readthedocs.io/en/latest/v3/code-recipes.html?highlight=language#language-setting) to set the language has no effect on the status object.

    config_dict = get_default_config()
    config_dict['language'] = 'de'

    owm = pyowm.OWM(API_KEY, config_dict)

I'm using python 3.8 and pyowm 3.2.0

csparpa commented 3 years ago

Hi @padmalcom Your question had already been arisen - please refer to this issue

In short: the OWM API only localizes detailed_status values, not status values

So you need to get the former instead of the latter if you need weather descriptions in German

An example:

from pyowm.owm import OWM
from pyowm.utils.config import get_default_config

config_dict = get_default_config()
config_dict['language'] = 'de'
owm = OWM(API_KEY, config_dict)

lat, lon = 52.518790, 13.377078  # Reichstagsgebäude (Berlin)

wm = owm.weather_manager()
weather_obj = wm.one_call(lat, lon).current

print(weather_obj.status)  # Clouds
print(weather_obj.detailed_status)  # 'Überwiegend bewölkt'

I will indeed make the documentation more clear, thanks for pointing this out

padmalcom commented 3 years ago

@csparpa Hi Claudio, thank's for the quick reply, I'll change the property accordingly.