From 182dc60e00ced5e8fd1f1e3713aa7b6c3fc0b4f3 Mon Sep 17 00:00:00 2001 From: poire-z Date: Wed, 26 Feb 2020 08:34:42 +0100 Subject: [PATCH] [i18n] allow translation of time (12/24-hours formats) (#5898) Discussion around https://github.com/koreader/koreader/issues/5359#issuecomment-590593945 --- frontend/apps/reader/modules/readerfooter.lua | 11 +++++++++-- frontend/ui/widget/touchmenu.lua | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/frontend/apps/reader/modules/readerfooter.lua b/frontend/apps/reader/modules/readerfooter.lua index cd6194828..e33cd657b 100644 --- a/frontend/apps/reader/modules/readerfooter.lua +++ b/frontend/apps/reader/modules/readerfooter.lua @@ -157,9 +157,16 @@ local footerTextGeneratorMap = { local prefix = symbol_prefix[symbol_type].time local clock if footer.settings.time_format == "12" then - clock = os.date("%I:%M%p") + if os.date("%p") == "AM" then + -- @translators This is the time in the morning in the 12-hour clock (%I is the hour, %M the minute). + clock = os.date(_("%I:%M AM")) + else + -- @translators This is the time in the afternoon in the 12-hour clock (%I is the hour, %M the minute). + clock = os.date(_("%I:%M PM")) + end else - clock = os.date("%H:%M") + -- @translators This is the time in the 24-hour clock (%H is the hour, %M the minute). + clock = os.date(_("%H:%M")) end if not prefix then return clock diff --git a/frontend/ui/widget/touchmenu.lua b/frontend/ui/widget/touchmenu.lua index 9d376ef85..c0c313bef 100644 --- a/frontend/ui/widget/touchmenu.lua +++ b/frontend/ui/widget/touchmenu.lua @@ -619,9 +619,16 @@ function TouchMenu:updateItems() local time_info_txt if G_reader_settings:nilOrTrue("twelve_hour_clock") then - time_info_txt = os.date("%I:%M %p") + if os.date("%p") == "AM" then + -- @translators This is the time in the morning in the 12-hour clock (%I is the hour, %M the minute). + time_info_txt = os.date(_("%I:%M AM")) + else + -- @translators This is the time in the afternoon in the 12-hour clock (%I is the hour, %M the minute). + time_info_txt = os.date(_("%I:%M PM")) + end else - time_info_txt = os.date("%H:%M") + -- @translators This is the time in the 24-hour clock (%H is the hour, %M the minute). + time_info_txt = os.date(_("%H:%M")) end local powerd = Device:getPowerDevice() local batt_lvl = powerd:getCapacity()