From c8e55ec9970821d5c287af21762265c312cc6292 Mon Sep 17 00:00:00 2001 From: zwim <36999612+zwim@users.noreply.github.com> Date: Sun, 26 Sep 2021 00:30:34 +0200 Subject: [PATCH] Autowarmth text formatting (#8262) * Wordings; easier translation formatting * use variable for tab_width (18) * Add an indent parameter for formatting --- plugins/autowarmth.koplugin/main.lua | 48 +++++++++++++++------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/plugins/autowarmth.koplugin/main.lua b/plugins/autowarmth.koplugin/main.lua index 07809eb9b..35d4ef7a5 100644 --- a/plugins/autowarmth.koplugin/main.lua +++ b/plugins/autowarmth.koplugin/main.lua @@ -720,11 +720,10 @@ function AutoWarmth:getWarmthMenu() }, getWarmthMenuEntry(_("Solar noon"), 6, false), getWarmthMenuEntry(_("Daytime"), 5), - getWarmthMenuEntry(_("Darkest time of civil dawn"), 4, false), - getWarmthMenuEntry(_("Darkest time of civil twilight"), 4, true), - getWarmthMenuEntry(_("Darkest time of nautical dawn"), 3, false), - getWarmthMenuEntry(_("Darkest time of astronomical dawn"), 2, false), - getWarmthMenuEntry(_("Midnight"), 1, false), + getWarmthMenuEntry(_("Darkest time of civil twilight"), 4), + getWarmthMenuEntry(_("Darkest time of nautical twilight"), 3, false), + getWarmthMenuEntry(_("Darkest time of astronomical twilight"), 2, false), + getWarmthMenuEntry(_("Solar midnight"), 1, false), } return tidy_menu(retval, self.easy_mode) @@ -749,8 +748,10 @@ function AutoWarmth:showTimesInfo(title, location, activator, request_easy) -- text to show -- t .. times -- num .. index in times - local function info_line(text, t, num, easy) - local retval = text .. self:hoursToClock(t[num]) + local function info_line(indent, text, t, num, easy) + local tab_width = 18 - indent + local retval = string.rep(" ", indent) .. text .. string.rep(" ", tab_width - text:len()) + .. self:hoursToClock(t[num]) if easy then if t[num] and self.current_times[num] and self.current_times[num] ~= t[num] then return text .. "\n" @@ -793,22 +794,23 @@ function AutoWarmth:showTimesInfo(title, location, activator, request_easy) face = Font:getFace("scfont"), width = math.floor(Screen:getWidth() * (self.easy_mode and 0.75 or 0.90)), text = title .. location_string .. ":\n\n" .. - info_line(_("Solar midnight: "), times, 1, request_easy) .. - _(" Dawn\n") .. - info_line(_(" Astronomic: "), times, 2, request_easy) .. - info_line(_(" Nautical: "), times, 3, request_easy).. - info_line(_(" Civil: "), times, 4) .. - _(" Dawn\n") .. - info_line(_("Sunrise: "), times, 5) .. - info_line(_("\nSolar noon: "), times, 6, request_easy) .. - - info_line(_("\nSunset: "), times, 7) .. - _(" Dusk\n") .. - info_line(_(" Civil: "), times, 8) .. - info_line(_(" Nautical: "), times, 9, request_easy) .. - info_line(_(" Astronomic: "), times, 10, request_easy) .. - _(" Dusk\n") .. - info_line(_("Solar midnight: "), times, midnight_index, request_easy) + info_line(0, _("Solar midnight:"), times, 1, request_easy) .. + " " .. _("Dawn") .. "\n" .. + info_line(4, _("Astronomic:"), times, 2, request_easy) .. + info_line(4, _("Nautical:"), times, 3, request_easy).. + info_line(4, _("Civil:"), times, 4) .. + " " .. _("Dawn\n") .. + info_line(0, _("Sunrise:"), times, 5) .. + "\n" .. + info_line(0, _("Solar noon:"), times, 6, request_easy) .. + "\n" .. + info_line(0, _("Sunset:"), times, 7) .. + " " .. _("Dusk") .. "\n" .. + info_line(4, _("Civil:"), times, 8) .. + info_line(4, _("Nautical:"), times, 9, request_easy) .. + info_line(4, _("Astronomic:"), times, 10, request_easy) .. + " " .. _("Dusk") .. "\n" .. + info_line(0, _("Solar midnight:"), times, midnight_index, request_easy) }) end