mirror of
https://github.com/koreader/koreader
synced 2024-11-10 01:10:34 +00:00
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
This commit is contained in:
parent
5cf72b6eea
commit
55259846a8
@ -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 }
|
local stop_month = os.time{year=year_end, month=month_end, day=1, hour=0, min=0 }
|
||||||
table.insert(results, {
|
table.insert(results, {
|
||||||
date_text,
|
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()
|
callback = function()
|
||||||
self:callbackMonthly(start_month, stop_month, date_text, book_mode)
|
self:callbackMonthly(start_month, stop_month, date_text, book_mode)
|
||||||
end,
|
end,
|
||||||
@ -1907,7 +1907,7 @@ function ReaderStatistics:getDatesFromAll(sdays, ptype, book_mode)
|
|||||||
begin_week = begin_week - weekday * 86400
|
begin_week = begin_week - weekday * 86400
|
||||||
table.insert(results, {
|
table.insert(results, {
|
||||||
date_text,
|
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()
|
callback = function()
|
||||||
self:callbackWeekly(begin_week, begin_week + 7 * 86400, date_text, book_mode)
|
self:callbackWeekly(begin_week, begin_week + 7 * 86400, date_text, book_mode)
|
||||||
end,
|
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))
|
- 60 * tonumber(string.sub(time_book,3,4)) - tonumber(string.sub(time_book,5,6))
|
||||||
table.insert(results, {
|
table.insert(results, {
|
||||||
date_text,
|
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()
|
callback = function()
|
||||||
self:callbackDaily(begin_day, begin_day + 86400, date_text)
|
self:callbackDaily(begin_day, begin_day + 86400, date_text)
|
||||||
end,
|
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 }
|
day=string.sub(result_book[1][i],9,10), hour=0, min=0, sec=0 }
|
||||||
table.insert(results, {
|
table.insert(results, {
|
||||||
result_book[1][i],
|
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()
|
callback = function()
|
||||||
local kv = self.kv
|
local kv = self.kv
|
||||||
UIManager:close(kv)
|
UIManager:close(kv)
|
||||||
@ -1984,8 +1984,8 @@ function ReaderStatistics:getBooksFromPeriod(period_begin, period_end, callback_
|
|||||||
local results = {}
|
local results = {}
|
||||||
local sql_stmt_res_book = [[
|
local sql_stmt_res_book = [[
|
||||||
SELECT book_tbl.title AS title,
|
SELECT book_tbl.title AS title,
|
||||||
sum(page_stat_tbl.duration),
|
|
||||||
count(distinct page_stat_tbl.page),
|
count(distinct page_stat_tbl.page),
|
||||||
|
sum(page_stat_tbl.duration),
|
||||||
book_tbl.id
|
book_tbl.id
|
||||||
FROM page_stat AS page_stat_tbl, book AS book_tbl
|
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
|
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
|
for i=1, #result_book.title do
|
||||||
table.insert(results, {
|
table.insert(results, {
|
||||||
result_book[1][i],
|
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]),
|
book_id = tonumber(result_book[4][i]),
|
||||||
callback = function()
|
callback = function()
|
||||||
local kv = self.kv
|
local kv = self.kv
|
||||||
@ -2111,7 +2111,7 @@ function ReaderStatistics:getDatesForBook(id_book)
|
|||||||
for i=1, #result_book.dates do
|
for i=1, #result_book.dates do
|
||||||
table.insert(results, {
|
table.insert(results, {
|
||||||
result_book[1][i],
|
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)
|
hold_callback = function(kv_page, kv_item)
|
||||||
self:resetStatsForBookForPeriod(id_book, result_book[4][i], result_book[5][i], result_book[1][i], function()
|
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
|
kv_page:removeKeyValueItem(kv_item) -- Reset, refresh what's displayed
|
||||||
|
Loading…
Reference in New Issue
Block a user