From 55259846a897d832870652d33b3cb56f1ac1a8d4 Mon Sep 17 00:00:00 2001 From: melyux <10296053+melyux@users.noreply.github.com> Date: Mon, 20 Feb 2023 00:56:04 -0800 Subject: [PATCH] Fix N_() usages, rearrange a SQL select (#10146) Fix some of my early blunders in using the `N_()` gettext function. Mini-PR from https://github.com/koreader/koreader/pull/9924#discussion_r1104298501 (@Frenzie). There was also one line for generating this same `%1 (%2 pages)` text that confusingly uses different ordering in the SQL query output; switched the two SELECT arguments around to make it match the other 5 usages. Works the same as before --- plugins/statistics.koplugin/main.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index 7a34f5fd2..20d2f5a81 100644 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -1893,7 +1893,7 @@ function ReaderStatistics:getDatesFromAll(sdays, ptype, book_mode) local stop_month = os.time{year=year_end, month=month_end, day=1, hour=0, min=0 } table.insert(results, { date_text, - T(N_("%1 (%2 page)", "%1 (%2 pages)", tonumber(result_book[2][i])), datetime.secondsToClockDuration(user_duration_format, tonumber(result_book[3][i]), false), tonumber(result_book[2][i])), + T(N_("%1 (1 page)", "%1 (%2 pages)", tonumber(result_book[2][i])), datetime.secondsToClockDuration(user_duration_format, tonumber(result_book[3][i]), false), tonumber(result_book[2][i])), callback = function() self:callbackMonthly(start_month, stop_month, date_text, book_mode) end, @@ -1907,7 +1907,7 @@ function ReaderStatistics:getDatesFromAll(sdays, ptype, book_mode) begin_week = begin_week - weekday * 86400 table.insert(results, { date_text, - T(N_("%1 (%2 page)", "%1 (%2 pages)", tonumber(result_book[2][i])), datetime.secondsToClockDuration(user_duration_format, tonumber(result_book[3][i]), false), tonumber(result_book[2][i])), + T(N_("%1 (1 page)", "%1 (%2 pages)", tonumber(result_book[2][i])), datetime.secondsToClockDuration(user_duration_format, tonumber(result_book[3][i]), false), tonumber(result_book[2][i])), callback = function() self:callbackWeekly(begin_week, begin_week + 7 * 86400, date_text, book_mode) end, @@ -1918,7 +1918,7 @@ function ReaderStatistics:getDatesFromAll(sdays, ptype, book_mode) - 60 * tonumber(string.sub(time_book,3,4)) - tonumber(string.sub(time_book,5,6)) table.insert(results, { date_text, - T(N_("%1 (%2 page)", "%1 (%2 pages)", tonumber(result_book[2][i])), datetime.secondsToClockDuration(user_duration_format, tonumber(result_book[3][i]), false), tonumber(result_book[2][i])), + T(N_("%1 (1 page)", "%1 (%2 pages)", tonumber(result_book[2][i])), datetime.secondsToClockDuration(user_duration_format, tonumber(result_book[3][i]), false), tonumber(result_book[2][i])), callback = function() self:callbackDaily(begin_day, begin_day + 86400, date_text) end, @@ -1959,7 +1959,7 @@ function ReaderStatistics:getDaysFromPeriod(period_begin, period_end) day=string.sub(result_book[1][i],9,10), hour=0, min=0, sec=0 } table.insert(results, { result_book[1][i], - T(N_("%1 (%2 page)", "%1 (%2 pages)", tonumber(result_book[2][i])), datetime.secondsToClockDuration(user_duration_format, tonumber(result_book[3][i]), false), tonumber(result_book[2][i])), + T(N_("%1 (1 page)", "%1 (%2 pages)", tonumber(result_book[2][i])), datetime.secondsToClockDuration(user_duration_format, tonumber(result_book[3][i]), false), tonumber(result_book[2][i])), callback = function() local kv = self.kv UIManager:close(kv) @@ -1984,8 +1984,8 @@ function ReaderStatistics:getBooksFromPeriod(period_begin, period_end, callback_ local results = {} local sql_stmt_res_book = [[ SELECT book_tbl.title AS title, - sum(page_stat_tbl.duration), count(distinct page_stat_tbl.page), + sum(page_stat_tbl.duration), book_tbl.id FROM page_stat AS page_stat_tbl, book AS book_tbl WHERE page_stat_tbl.id_book=book_tbl.id AND page_stat_tbl.start_time BETWEEN %d AND %d @@ -2003,7 +2003,7 @@ function ReaderStatistics:getBooksFromPeriod(period_begin, period_end, callback_ for i=1, #result_book.title do table.insert(results, { result_book[1][i], - T(N_("%1 (%2 page)", "%1 (%2 pages)", tonumber(result_book[3][i])), datetime.secondsToClockDuration(user_duration_format, tonumber(result_book[2][i]), false), tonumber(result_book[3][i])), + T(N_("%1 (1 page)", "%1 (%2 pages)", tonumber(result_book[2][i])), datetime.secondsToClockDuration(user_duration_format, tonumber(result_book[3][i]), false), tonumber(result_book[2][i])), book_id = tonumber(result_book[4][i]), callback = function() local kv = self.kv @@ -2111,7 +2111,7 @@ function ReaderStatistics:getDatesForBook(id_book) for i=1, #result_book.dates do table.insert(results, { result_book[1][i], - T(N_("%1 (%2 page)", "%1 (%2 pages)", tonumber(result_book[2][i])), datetime.secondsToClockDuration(user_duration_format, tonumber(result_book[3][i]), false), tonumber(result_book[2][i])), + T(N_("%1 (1 page)", "%1 (%2 pages)", tonumber(result_book[2][i])), datetime.secondsToClockDuration(user_duration_format, tonumber(result_book[3][i]), false), tonumber(result_book[2][i])), hold_callback = function(kv_page, kv_item) self:resetStatsForBookForPeriod(id_book, result_book[4][i], result_book[5][i], result_book[1][i], function() kv_page:removeKeyValueItem(kv_item) -- Reset, refresh what's displayed