csparpa / pyowm

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

Language support again #358

Closed JamesGitRichards closed 3 years ago

JamesGitRichards commented 3 years ago

Hi! I've tried to get information about weather in this library in certain language. I've tried to set the language in get_default_config and in json settings file but it's doesn't work for both. How can I use any language in this lib? I'm using python 3.8.6. Here is code for main.py and set.json.

import pyowm
from pyowm.utils.config import get_config_from
config_dict = get_config_from("path")  

city = "New York"
owm = pyowm.OWM("api",  config_dict )
mgr = owm.weather_manager()
observation = mgr.weather_at_place(city)
w = observation.weather
print(w.status)
{
    "subscription_type": "free",
    "language": "fr",
    "connection": {
        "use_ssl": true,
        "verify_ssl_certs": true,
        "use_proxy": false,
        "timeout_secs": 5
    },
    "proxies": {
        "http": "Not use",
        "https": "Not use"
    }
}
csparpa commented 3 years ago

Hi @JamesGitRichards

I found out why.

This comes straight from the OWM API: it does return localized detailed status text but it does not return localized status along

In code:

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

config_dict = get_default_config()
config_dict['language'] = 'fr'
owm = OWM('apikey', config_dict)

city = "New York"
mgr = owm.weather_manager()
observation = mgr.weather_at_place(city)
w = observation.weather

print(w.status)  # Clouds
print(w.detailed_status)  # couvert

My fault on this: the documentation was not clear enough about it - I've patched it

Hope this helps Cheers

padmalcom commented 3 years ago

Okay, I tested detailed_status with language set to 'de' but it had no effect.