From e4dd1826fae9c014c2509254a09639eda9689f10 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 28 Nov 2019 23:22:07 +0100 Subject: [PATCH] Translate file size unit (#5651) Close #5649 --- frontend/util.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/frontend/util.lua b/frontend/util.lua index e1a7f0b31..03529bdf1 100644 --- a/frontend/util.lua +++ b/frontend/util.lua @@ -656,17 +656,21 @@ end function util.getFriendlySize(size) size = tonumber(size) if not size or type(size) ~= "number" then return end - local s if size > 1024*1024*1024 then - s = string.format("%4.1f GB", size/1024/1024/1024) - elseif size > 1024*1024 then - s = string.format("%4.1f MB", size/1024/1024) - elseif size > 1024 then - s = string.format("%4.1f KB", size/1024) + -- @translators This is an abbreviation for the gigabyte, a unit of computer memory or data storage capacity. + return T(_("%1 GB"), string.format("%4.1f", size/1024/1024/1024)) + end + if size > 1024*1024 then + -- @translators This is an abbreviation for the megabyte, a unit of computer memory or data storage capacity. + return T(_("%1 MB"), string.format("%4.1f", size/1024/1024)) + end + if size > 1024 then + -- @translators This is an abbreviation for the kilobyte, a unit of computer memory or data storage capacity. + return T(_("%1 KB"), string.format("%4.1f", size/1024)) else - s = string.format("%d B", size) + -- @translators This is an abbreviation for the byte, a unit of computer memory or data storage capacity. + return T(_("%1 B"), string.format("%d", size)) end - return s end --- Gets formatted size as string (1273334 => "1,273,334")