V
V
Valera7892020-02-10 12:49:46
API
Valera789, 2020-02-10 12:49:46

Yandex weather api, how to get an answer in Russian?

I send a request to https://api.weather.yandex.ru/v1/forecast?lang=ru_...

the response is returned to en although lang=ru_Ru is wrong

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Athanor, 2020-02-11
@Valera789

Really strange.
We asked Yandex technical support and this is the answer we received:


Do I understand correctly that you are confused by symbols like condition: "partly-cloudy-and-light-snow"? The fact is that these are essentially codes, not text fields. Therefore, they will be displayed in English in any interface language.
To understand if lang works or not, please pay attention to the url field. In the handle of the informer, when the language changes, the url will change.

What to do if you still need to get a translation of these same ones ? One option is to write an array map yourself. There will be something like this:condition: "partly-cloudy-and-light-snow"
const yandexResponse = await getForecast();
const weatherTranslations = {
 'partly-cloudy-and-light-snow': 'небольшой снег'
};
console.log(weatherTranslations[yandexResponse.fact.condition])

All translations can be taken from the documentation .

H
hzzzzl, 2020-02-10
@hzzzzl

caps, " ru_RU " is the Russian language for the Russian domain.
https://yandex.ru/dev/weather/doc/dg/concepts/fore...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question