csparpa / pyowm

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

Add list of supported languages #339

Closed Misiu closed 3 years ago

Misiu commented 3 years ago

Currently, in Home Assisnatt the list of supported languages is added to Home Assistant, but as suggested by one of the contributors, ideally it should be added to your package. My recent PR is adding the whole list of languages from OWM website.

Consider adding this as a const.

csparpa commented 3 years ago

Thanks, will do. I will try to use standard ISO labelling for supported languages

Misiu commented 3 years ago

Thanks, looking forward to that! The list of supported languages is here: https://openweathermap.org/forecast5#multi In my PR I've added the following list:

LANGUAGES = [
    "af",
    "al",
    "ar",
    "az",
    "bg",
    "ca",
    "cz",
    "da",
    "de",
    "el",
    "en",
    "es",
    "eu",
    "fa",
    "fi",
    "fr",
    "gl",
    "he",
    "hi",
    "hr",
    "hu",
    "id",
    "it",
    "ja",
    "kr",
    "la",
    "lt",
    "mk",
    "nl",
    "no",
    "pl",
    "pt",
    "pt_br",
    "ro",
    "ru",
    "se",
    "sk",
    "sl",
    "sp",
    "sr",
    "sv",
    "th",
    "tr",
    "ua",
    "uk",
    "vi",
    "zh_cn",
    "zh_tw",
    "zu",
]
csparpa commented 3 years ago

Ok @Misiu , it's in.

Commit eb1f943e804e1a056a49e95a35744eca80b0e1ae on branch develop

As easy as:

from pyowm.owm import OWM
owm = OWM('your-api-key')
owm.supported_languages
Misiu commented 3 years ago

@csparpa that was quick 😃 can I use that const without creating an OWM instance? I need to get a list of supported languages before I create owm. Sorry for a newbie question but I'm new to Pyhon.

csparpa commented 3 years ago

Yes you can, the constant is in module

https://github.com/csparpa/pyowm/blob/develop/pyowm/constants.py

Just import that with:

from pyowm.constants import LANGUAGES

On Wed, Sep 23, 2020, 19:28 Tomasz notifications@github.com wrote:

@csparpa https://github.com/csparpa that was quick 😃 can I use that const without creating an OWM instance? I need to get a list of supported languages before I create owm. Sorry for a newbie question but I'm new to Pyhon.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/csparpa/pyowm/issues/339#issuecomment-697747032, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHOXXVJFWS25HHGUUR6RF3SHIV47ANCNFSM4RWVIFQQ .

Misiu commented 3 years ago

@csparpa thank you 👍 now let's wait for 3.1 to get released.