A
A
apiwi2020-06-16 14:08:06
Python
apiwi, 2020-06-16 14:08:06

How to change language in PyOwm?

The language does not change in pyowm, I take the key from OpenWeather, I had to do it through a translator, how to fix it?

owm = pyowm.OWM('ключ из openweaher', language = "RU") # тут пробовал и ru, все равно английский 
              observation = owm.weather_at_place(city)
              w = observation.get_weather()
              temperature = w.get_temperature('celsius')['temp']
              translator= Translator(from_lang="english",to_lang="russian")
              self.write_msg(id, "В городе " + city.title() + " " + str(math.ceil(temperature)) + "°. " + "Вижу: " + translator.translate(w.get_status()))


5ee8a7b0e8b92150885618.jpeg

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
soremix, 2020-06-16
@apiwi

w.get_detailed_status()

I
iNfeRNoGIZA, 2020-08-28
@iNfeRNoGIZA

I read some documentation and made the translation in this way :)

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

place = input(" Введите город/страну: ")

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

owm = OWM( 'API-Key', config_dict  )

mgr = owm.weather_manager()
observation = mgr.weather_at_place(place)
w = observation.weather

print(w)

S
ScriptKiddo, 2020-06-16
@ScriptKiddo

Actual for version PyOWM 3.0.0

import pyowm
from pyowm.commons.enums import SubscriptionTypeEnum
from pyowm.utils.measurables import kelvin_to_celsius

city = 'Moscow'

config = {
    'subscription_type': SubscriptionTypeEnum.FREE,
    'language': 'ru',
    'connection': {
        'use_ssl': True,
        'verify_ssl_certs': True,
        'use_proxy': False,
        'timeout_secs': 5
    },
    'proxies': {
        'http': 'http://user:[email protected]:port',
        'https': 'socks5://user:[email protected]:port'
    }
}
owm = pyowm.OWM('', config=config)
mgr = owm.weather_manager()
observation = mgr.weather_at_place(city)
w = observation.weather

print("В городе " + city + " сейчас температура: " + str(kelvin_to_celsius(w.temp['temp'])) + " по Цельсию.")
print('Погода в указанном городе: ' + observation.location.name)

I
ID-B, 2021-10-04
@ID-B

Nothing worked(

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question