From 5c9dc850e858b748fce95d8d574b1275ece09e90 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Sat, 16 Jan 2021 21:40:00 +0100 Subject: [PATCH] Address assorted Weblate comments (#7154) * Fix typo in dropbox Reported by @lescheck * Rephrase text justification explanation more elegantly * CoverBrowser: fix up some plurals * Statistics: remove random use of template function * Use ngettext for minute/minutes and second/seconds * Change KB/MB/GB to kB/MB/GB SI units --- frontend/apps/cloudstorage/dropbox.lua | 2 +- frontend/ui/data/css_tweaks.lua | 2 +- frontend/ui/elements/screen_android.lua | 7 ++++--- frontend/util.lua | 12 +++++------ plugins/coverbrowser.koplugin/listmenu.lua | 4 ++-- plugins/statistics.koplugin/main.lua | 3 ++- spec/unit/util_spec.lua | 24 +++++++++++----------- 7 files changed, 28 insertions(+), 26 deletions(-) diff --git a/frontend/apps/cloudstorage/dropbox.lua b/frontend/apps/cloudstorage/dropbox.lua index 40b3ffbe0..5c28ff1a3 100644 --- a/frontend/apps/cloudstorage/dropbox.lua +++ b/frontend/apps/cloudstorage/dropbox.lua @@ -142,7 +142,7 @@ function DropBox:info(token) local info = DropBoxApi:fetchInfo(token) local info_text if info and info.name then - info_text = T(_"Type: %1\nName: %2\nEmail: %3\nCounty: %4", + info_text = T(_"Type: %1\nName: %2\nEmail: %3\nCountry: %4", "Dropbox",info.name.display_name, info.email, info.country) else info_text = _("No information available") diff --git a/frontend/ui/data/css_tweaks.lua b/frontend/ui/data/css_tweaks.lua index 5e4f0bc36..f3fbaada6 100644 --- a/frontend/ui/data/css_tweaks.lua +++ b/frontend/ui/data/css_tweaks.lua @@ -164,7 +164,7 @@ h1 + h6, h2 + h6, h3 + h6, h4 + h6, h5 + h6 { page-break-before: avoid !importan { id = "text_align_all_justify", title = _("Justify all elements"), - description = _("Text justification is the default, but it may be overridden by publisher styles. This will re-enable it for all elements, which may lose centering in some of them."), + description = _("Text justification is the default, but it may be overridden by publisher styles. This will force justification on all elements, some of which may not be centered as expected."), css = [[* { text-align: justify !important; }]], separator = true, }, diff --git a/frontend/ui/elements/screen_android.lua b/frontend/ui/elements/screen_android.lua index c1b5731b2..81e160a4c 100644 --- a/frontend/ui/elements/screen_android.lua +++ b/frontend/ui/elements/screen_android.lua @@ -5,6 +5,7 @@ local ffi = require("ffi") local logger = require("logger") local _ = require("gettext") local Input = Device.input +local N_ = _.ngettext local Screen = Device.screen local T = require("ffi/util").template @@ -25,10 +26,10 @@ local timeout_custom7 = 30 * 60 * 1000 local function humanReadableTimeout(timeout) local sec = timeout / 1000 - if sec >= 120 then - return T(_("%1 minutes"), sec / 60) + if sec >= 60 then + return T(N_("1 minute", "%1 minutes", sec), sec / 60) else - return T(_("%1 seconds"), sec) + return T(N_("1 second", "%1 seconds", sec), sec) end end diff --git a/frontend/util.lua b/frontend/util.lua index e43fcdc51..8d522c929 100644 --- a/frontend/util.lua +++ b/frontend/util.lua @@ -878,17 +878,17 @@ function util.getFriendlySize(size, right_align) local deci_format = right_align and "%6d" or "%d" size = tonumber(size) if not size or type(size) ~= "number" then return end - if size > 1024*1024*1024 then + if size > 1000*1000*1000 then -- @translators This is an abbreviation for the gigabyte, a unit of computer memory or data storage capacity. - return T(_("%1 GB"), string.format(frac_format, size/1024/1024/1024)) + return T(_("%1 GB"), string.format(frac_format, size/1000/1000/1000)) end - if size > 1024*1024 then + if size > 1000*1000 then -- @translators This is an abbreviation for the megabyte, a unit of computer memory or data storage capacity. - return T(_("%1 MB"), string.format(frac_format, size/1024/1024)) + return T(_("%1 MB"), string.format(frac_format, size/1000/1000)) end - if size > 1024 then + if size > 1000 then -- @translators This is an abbreviation for the kilobyte, a unit of computer memory or data storage capacity. - return T(_("%1 KB"), string.format(frac_format, size/1024)) + return T(_("%1 kB"), string.format(frac_format, size/1000)) else -- @translators This is an abbreviation for the byte, a unit of computer memory or data storage capacity. return T(_("%1 B"), string.format(deci_format, size)) diff --git a/plugins/coverbrowser.koplugin/listmenu.lua b/plugins/coverbrowser.koplugin/listmenu.lua index e380c8374..1a09c04ef 100644 --- a/plugins/coverbrowser.koplugin/listmenu.lua +++ b/plugins/coverbrowser.koplugin/listmenu.lua @@ -411,9 +411,9 @@ function ListMenuItem:update() -- Display these instead of the read % if pages then if status == "complete" then - pages_str = T(_("Finished - %1 pages"), pages) + pages_str = T(N_("Finished – 1 page", "Finished – %1 pages", pages), pages) else - pages_str = T(_("On hold - %1 pages"), pages) + pages_str = T(N_("On hold – 1 page", "On hold – %1 pages", pages), pages) end else pages_str = status == "complete" and _("Finished") or _("On hold") diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index b31ec75b2..3d1759144 100644 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -1023,7 +1023,8 @@ The max value ensures a page you stay on for a long time (because you fell aslee }) else UIManager:show(InfoMessage:new{ - text =T(_("Reading progress unavailable.\nNo data from last %1 days."),7)}) + text = _("Reading progress is not available.\nThere is no data for the last week."), + }) end end }, diff --git a/spec/unit/util_spec.lua b/spec/unit/util_spec.lua index 08c974730..1e7fa0d85 100644 --- a/spec/unit/util_spec.lua +++ b/spec/unit/util_spec.lua @@ -332,19 +332,19 @@ describe("util module", function() describe("should convert bytes to friendly size as string", function() it("to 100.0 GB", function() assert.is_equal("100.0 GB", - util.getFriendlySize(100*1024*1024*1024)) + util.getFriendlySize(100*1000*1000*1000)) end) it("to 1.0 GB", function() assert.is_equal("1.0 GB", - util.getFriendlySize(1024*1024*1024+1)) + util.getFriendlySize(1000*1000*1000+1)) end) it("to 1.0 MB", function() assert.is_equal("1.0 MB", - util.getFriendlySize(1024*1024+1)) + util.getFriendlySize(1000*1000+1)) end) - it("to 1.0 KB", function() - assert.is_equal("1.0 KB", - util.getFriendlySize(1024+1)) + it("to 1.0 kB", function() + assert.is_equal("1.0 kB", + util.getFriendlySize(1000+1)) end) it("to B", function() assert.is_equal("10 B", @@ -352,19 +352,19 @@ describe("util module", function() end) it("to 100.0 GB with minimum field width alignment", function() assert.is_equal(" 100.0 GB", - util.getFriendlySize(100*1024*1024*1024, true)) + util.getFriendlySize(100*1000*1000*1000, true)) end) it("to 1.0 GB with minimum field width alignment", function() assert.is_equal(" 1.0 GB", - util.getFriendlySize(1024*1024*1024+1, true)) + util.getFriendlySize(1000*1000*1000+1, true)) end) it("to 1.0 MB with minimum field width alignment", function() assert.is_equal(" 1.0 MB", - util.getFriendlySize(1024*1024+1, true)) + util.getFriendlySize(1000*1000+1, true)) end) - it("to 1.0 KB with minimum field width alignment", function() - assert.is_equal(" 1.0 KB", - util.getFriendlySize(1024+1, true)) + it("to 1.0 kB with minimum field width alignment", function() + assert.is_equal(" 1.0 kB", + util.getFriendlySize(1000+1, true)) end) it("to B with minimum field width alignment", function() assert.is_equal(" 10 B",