Various applications of util.template

This is the first bunch for #1276. I'd like to resolve #1281 before doing more.
pull/1284/head
Frans de Jonge 10 years ago
parent cf93605d04
commit 66f04af8fb

@ -256,16 +256,15 @@ function FileManager:deleteFile(file)
end
end
local collates = {
strcoll = _("Title"),
access = _("Recent"),
}
function FileManager:getSortingMenuTable()
local fm = self
local collates = {
strcoll = {_("by title"), _("Sort by title")},
access = {_("by date"), _("Sort by date")},
}
local set_collate_table = function(collate)
return {
text = collates[collate],
text = collates[collate][2],
checked_func = function()
return fm.file_chooser.collate == collate
end,
@ -274,7 +273,10 @@ function FileManager:getSortingMenuTable()
end
return {
text_func = function()
return _("Sort order: ") .. collates[fm.file_chooser.collate]
return util.template(
_("Sort order: %1"),
collates[fm.file_chooser.collate][1]
)
end,
sub_item_table = {
set_collate_table("strcoll"),

@ -10,6 +10,7 @@ local Event = require("ui/event")
local UIManager = require("ui/uimanager")
local Screen = require("device").screen
local DEBUG = require("dbg")
local T = require("ffi/util").template
local _ = require("gettext")
local ReaderFont = InputContainer:new{
@ -210,7 +211,7 @@ end
function ReaderFont:makeDefault(face)
if face then
UIManager:show(ConfirmBox:new{
text = _("Set default font to ")..face.."?",
text = T( _("Set default font to %1?"), face),
ok_callback = function()
G_reader_settings:saveSetting("cre_font", face)
end,

@ -5,6 +5,7 @@ local lfs = require("libs/libkoreader-lfs")
local UIManager = require("ui/uimanager")
local Device = require("device")
local DEBUG = require("dbg")
local T = require("ffi/util").template
local _ = require("gettext")
local OTAManager = {
@ -114,9 +115,11 @@ function OTAManager:fetchAndProcessUpdate()
})
elseif ota_version then
UIManager:show(ConfirmBox:new{
text = _("Do you want to update?\n") ..
_("Installed version: ") .. local_version .. "\n" ..
_("Available version: ") .. ota_version .. "\n",
text = T(
_("Do you want to update?\nInstalled version: %1\nAvailable version: %2"),
local_version,
ota_version
),
ok_callback = function()
UIManager:show(InfoMessage:new{
text = _("Downloading may take several minutes..."),

@ -461,19 +461,34 @@ function UIManager:getRefreshMenuTable()
callback = function() UIManager:setRefreshRate(6) end,
},
{
text_func = function() return _("Custom ") .. "1: " .. custom_1() .. _(" pages") end,
text_func = function()
return util.template(
_("Custom 1: %1 pages"),
custom_1()
)
end,
checked_func = function() return UIManager:getRefreshRate() == custom_1() end,
callback = function() UIManager:setRefreshRate(custom_1()) end,
hold_input = custom_input("refresh_rate_1")
},
{
text_func = function() return _("Custom ") .. "2: " .. custom_2() .. _(" pages") end,
text_func = function()
return util.template(
_("Custom 2: %1 pages"),
custom_2()
)
end,
checked_func = function() return UIManager:getRefreshRate() == custom_2() end,
callback = function() UIManager:setRefreshRate(custom_2()) end,
hold_input = custom_input("refresh_rate_2")
},
{
text_func = function() return _("Custom ") .. "3: " .. custom_3() .. _(" pages") end,
text_func = function()
return util.template(
_("Custom 3: %1 pages"),
custom_3()
)
end,
checked_func = function() return UIManager:getRefreshRate() == custom_3() end,
callback = function() UIManager:setRefreshRate(custom_3()) end,
hold_input = custom_input("refresh_rate_3")

Loading…
Cancel
Save