[Feature] retrieve l18n Description from currentWeather by openweatherapi #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why did I need this
We used a custom openweatherapi integration that simply retrieved weather and description. But the implamantation was kindy sloppy so I checked out your extension. Everything was fine but you do not retrieve the description text and there was no documentation how I could simply translate by the icon => https://openweathermap.org/weather-conditions
But by analysing the data that we collected for a long time I retrieved following descriptions per icon (as file because it is a lot per code...) =>
openweaterapi-weathercodes.txt
Implementation
First of all I added a new field "languages" to the scheduler task "weather2". This is a comma separated list with IDs of the used languages of the page and per default it is -1 if empty. In the scheduler I added the lang param to the url (default: en), so I can switch the language as needed. In a loop I iterate over every ID that the user entered in the scheduler and via the site finder I retrieve the twoLetterIsoCode of the language, that will be sent to openweater.
Impact
Obviously as we added new language fields, we need to update the database structure. Furthermore the Scheduler task has to be executed one time to update those fields to be correctly displayed in the frontend.
Future
I have seen that the weather alert has hardcoded translations in it. Maybe the API retrieves the description the same way and you could implement it like I did, so you get the same translation as openweather, as seen in my .txt file with all of the codes, openweather uses different descriptions for the same code...