diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index 71c8bbca3..9612d69c8 100755 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -40,6 +40,31 @@ local ReaderStatistics = Widget:extend{ }, } +local shortDayOfWeekTranslation = { + ["Mon"] = _("Mon"), + ["Tue"] = _("Tue"), + ["Wed"] = _("Wed"), + ["Thu"] = _("Thu"), + ["Fri"] = _("Fri"), + ["Sat"] = _("Sat"), + ["Sun"] = _("Sun"), +} + +local monthTranslation = { + ["January"] = _("January"), + ["February"] = _("February"), + ["March"] = _("March"), + ["April"] = _("April"), + ["May"] = _("May"), + ["June"] = _("June"), + ["July"] = _("July"), + ["August"] = _("August"), + ["September"] = _("September"), + ["October"] = _("October"), + ["November"] = _("November"), + ["December"] = _("December"), +} + function ReaderStatistics:isDocless() return self.ui == nil or self.ui.document == nil end @@ -353,7 +378,7 @@ function ReaderStatistics:getDatesFromAll(sdays, ptype) local one_day = 24 * 3600 -- one day in seconds local avg_time_per_page local period = now_stamp - ((sdays -1) * one_day) - from_begin_day - for _, v in pairs(ReadHistory.hist) do + for __, v in pairs(ReadHistory.hist) do local book_stats = DocSettings:open(v.file):readSetting('stats') if book_stats ~= nil then -- if current reading book @@ -376,15 +401,17 @@ function ReaderStatistics:getDatesFromAll(sdays, ptype) table.sort(sorted_performance_in_pages) for i, n in pairs(sorted_performance_in_pages) do if ptype == "daily_weekday" then - date_text = os.date("%Y-%m-%d (%a)", n) + date_text = string.format("%s (%s)", + os.date("%Y-%m-%d", n), + shortDayOfWeekTranslation[os.date("%a", n)]) elseif ptype == "daily" then - date_text = os.date("%Y-%m-%d" , n) + date_text = os.date("%Y-%m-%d", n) elseif ptype == "weekly" then - date_text = os.date("%Y Week %W" , n) + date_text = T(_("%1 Week %2"), os.date("%Y "), os.date(" %W", n)) elseif ptype == "monthly" then - date_text = os.date("%B %Y" , n) + date_text = monthTranslation[os.date("%B", n)] .. os.date(" %Y", n) else - date_text = os.date("%Y-%m-%d" , n) + date_text = os.date("%Y-%m-%d", n) end --if ptype if not dates[date_text] then dates[date_text] = { diff --git a/plugins/statistics.koplugin/readerprogress.lua b/plugins/statistics.koplugin/readerprogress.lua index 82a3f1d84..bdbb540c8 100644 --- a/plugins/statistics.koplugin/readerprogress.lua +++ b/plugins/statistics.koplugin/readerprogress.lua @@ -26,6 +26,26 @@ local ReaderProgress = InputContainer:new{ padding = Screen:scaleBySize(15), } +local dayOfWeekTranslation = { + ["Monday"] = _("Monday"), + ["Tuesday"] = _("Tuesday"), + ["Wednesday"] = _("Wednesday"), + ["Thursday"] = _("Thursday"), + ["Friday"] = _("Friday"), + ["Saturday"] = _("Saturday"), + ["Sunday"] = _("Sunday"), +} + +local shortDayOfWeekTranslation = { + ["Mon"] = _("Mon"), + ["Tue"] = _("Tue"), + ["Wed"] = _("Wed"), + ["Thu"] = _("Thu"), + ["Fri"] = _("Fri"), + ["Sat"] = _("Sat"), + ["Sun"] = _("Sun"), +} + function ReaderProgress:init() self.small_font_face = Font:getFace("ffont", 15) self.medium_font_face = Font:getFace("ffont", 20) @@ -58,7 +78,10 @@ end function ReaderProgress:getTodayStats(dates) local today_time = 0 local today_pages = 0 - local today = os.date("%Y-%m-%d (%a)" , os.time()) + local now_time = os.time() + local today = string.format("%s (%s)", + os.date("%Y-%m-%d", now_time), + shortDayOfWeekTranslation[os.date("%a", now_time)]) if dates[today] ~= nil then today_time = dates[today].read today_pages = dates[today].count @@ -168,6 +191,7 @@ function ReaderProgress:genWeekStats(stats_day) local date_format local date_format_show local select_day_time + local diff_time local now_time = os.time() local height = Screen:scaleBySize(60) local statistics_container = CenterContainer:new{ @@ -199,13 +223,16 @@ function ReaderProgress:genWeekStats(stats_day) } for i = 1, stats_day , 1 do - date_format = os.date("%Y-%m-%d (%a)" , now_time - second_in_day * (i -1)) + diff_time = now_time - second_in_day * (i - 1) + date_format = string.format("%s (%s)", + os.date("%Y-%m-%d", diff_time), + shortDayOfWeekTranslation[os.date("%a", diff_time)]) if self.dates[date_format] ~= nil then select_day_time = self.dates[date_format].read else select_day_time = 0 end - date_format_show = os.date("%A (%d.%m)" , now_time - second_in_day * (i - 1)) + date_format_show = dayOfWeekTranslation[os.date("%A", diff_time)] .. os.date(" (%d.%m)", diff_time) local total_group = HorizontalGroup:new{ align = "center", padding = 2,