Skip to content

Commit

Permalink
Swedish translations
Browse files Browse the repository at this point in the history
Better error handling from OW API

UI tweaks
  • Loading branch information
ikubicki committed Sep 29, 2020
1 parent 835de60 commit e28bac4
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 8 deletions.
4 changes: 4 additions & 0 deletions GUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function GUI:label1Text(text, value1)
self.app:updateView("label1", "text", string.format(self.i18n:get(text), value1))
end

function GUI:label2Render()
self.app:updateView("label2", "text", self.i18n:get('select-sensors'))
end

function GUI:button3Render()
self.app:updateView('button3_1', 'text', string.format('[%s] ' .. self.i18n:get('openweather-temperature'), self:check(Toggles:get('temperature'))))
self.app:updateView('button3_2', 'text', string.format('[%s] ' .. self.i18n:get('openweather-wind'), self:check(Toggles:get('wind'))))
Expand Down
1 change: 0 additions & 1 deletion OpenWeather.fqa

This file was deleted.

1 change: 1 addition & 0 deletions OpenWeather110.fqa

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions i18n.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ phrases = {
pl = {
['name'] = 'Stacja pogodowa OpenWeather',
['refresh'] = 'Odśwież',
['refresh-sensors'] = 'Odśwież sensory',
['retry'] = 'Ponów',
['last-update'] = 'Ostatnia aktualizacja: %s',
['please-wait'] = 'Proszę czekać...',
['device-updated'] = 'Zaktualizowano %s',
['select-sensors'] = 'Kliknij w przyciski aby wybrać sensory:',
["openweather-provider"] = "Stacja OpenWeather",
["openweather-temperature"] = "Temperatura",
["openweather-pressure"] = "Ciśnienie",
Expand All @@ -37,9 +40,12 @@ phrases = {
en = {
['name'] = 'OpenWeather weather station',
['refresh'] = 'Refresh',
['refresh-sensors'] = 'Refresh sensors',
['retry'] = 'Retry',
['last-update'] = 'Last update at %s',
['please-wait'] = 'Please wait...',
['device-updated'] = '%s updated',
['select-sensors'] = 'Click on buttons to select sensors:',
["openweather-provider"] = "OpenWeather station",
["openweather-temperature"] = "Temperature",
["openweather-pressure"] = "Pressure",
Expand All @@ -54,9 +60,12 @@ phrases = {
de = {
['name'] = 'OpenWeather wetterstation',
['refresh'] = 'Aktualisieren',
['refresh-sensors'] = 'Sensoren aktualisieren',
['retry'] = 'Wiederholen',
['last-update'] = 'Letztes update: %s',
['please-wait'] = 'Ein moment bitte...',
['device-updated'] = '%s aktualisiert',
['select-sensors'] = 'Klicken Sie auf die Schaltflächen, um Sensoren auszuwählen:',
["openweather-provider"] = "OpenWeather station",
["openweather-temperature"] = "Temperatur",
["openweather-pressure"] = "Luftdruck",
Expand All @@ -67,5 +76,25 @@ phrases = {
["openweather-sunrise"] = "Sonnenaufgang",
["openweather-sunset"] = "Sonnenuntergang",
["openweather-uv"] = "UV-Index",
},
se = {
['name'] = 'OpenWeather väderstation',
['refresh'] = 'Uppdatera',
['refresh-sensors'] = 'Uppdatera sensorer',
['retry'] = 'Försök igen',
['last-update'] = 'Senaste uppdatering %s',
['please-wait'] = 'Vänligen vänta...',
['device-updated'] = '%s uppdaterad',
['select-sensors'] = 'Klicka på knapparna för att välja sensorer:',
["openweather-provider"] = "OpenWeather station",
["openweather-temperature"] = "Temperatur",
["openweather-pressure"] = "Lufttryck",
["openweather-humidity"] = "Fuktighet",
["openweather-wind"] = "Vind",
["openweather-rain"] = "Regn",
["openweather-clouds"] = "Moln",
["openweather-sunrise"] = "Soluppgång",
["openweather-sunset"] = "Solnedgång",
["openweather-uv"] = "UV-Index",
}
}
23 changes: 16 additions & 7 deletions main.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--[[
OpenWeather widget v 1.0.0
OpenWeather widget v 1.1.0
@author ikubicki
]]

Expand All @@ -8,6 +8,7 @@ function QuickApp:onInit()
self:initializeChildren()
self:trace('')
self:trace(self.i18n:get('name'))
GUI:label2Render()
GUI:button3Render()
self:run()
end
Expand All @@ -32,10 +33,17 @@ function QuickApp:pullOpenWeatherData()
local data = json.decode(response.data)
-- self:debug('today forecast', json.encode(data.daily[1]))
-- self:debug('tomorrow forecast', json.encode(data.daily[2]))
self:updateProvider(data.current)
self:updateDevices(data.current)
self:updateSunInfo(data.daily[1])
self:updateViewElements()
if data.cod and data.cod >= 400 then
self:error(data.message)
self.gui:label1Text(data.message)
self.gui:button1Text('retry')
else
self:updateProvider(data.current)
self:updateDevices(data.current)
self:updateSunInfo(data.daily[1])
self:updateViewElements()
end

end
self.http:get('/onecall' .. self:getUrlQueryString(), callback1)
end
Expand Down Expand Up @@ -68,7 +76,7 @@ function QuickApp:updateDevices(data)
-- CLOUDS
OWSensor:get('clouds'):update({value = data.clouds, unit = '%'})
-- RAIN
OWRain:get('rain'):update({value = OWRain:extractValue(data.rain), unit = 'mm'})
local rain = OWRain:get('rain'):update({value = OWRain:extractValue(data.rain), unit = 'mm'})
-- UVI
if data.uvi ~= nil then
OWSensor:get('uv'):update(data.uvi)
Expand Down Expand Up @@ -99,6 +107,7 @@ function QuickApp:toggleMetric(e)
if e.elementName == 'button3_8' then Toggles:toggle('sunrise') end
if e.elementName == 'button3_9' then Toggles:toggle('sunset') end
GUI:button3Render()
GUI:button1Text('refresh-sensors')
end

function QuickApp:getUrlQueryString()
Expand Down Expand Up @@ -145,4 +154,4 @@ function QuickApp:initializeChildren()
[OWHumidity.class] = OWHumidity,
[OWRain.class] = OWRain,
})
end
end

0 comments on commit e28bac4

Please sign in to comment.