2
0
mirror of https://github.com/koreader/koreader synced 2024-11-11 19:11:14 +00:00

First util.template encapsulated strings

This commit is contained in:
Frans de Jonge 2014-11-19 12:23:37 +01:00
parent 4efe036c2f
commit d701d9b198
4 changed files with 6 additions and 4 deletions

View File

@ -94,7 +94,7 @@ function ReaderBookmark:onShowBookmark()
if type(page) == "string" then if type(page) == "string" then
page = self.ui.document:getPageFromXPointer(v.page) page = self.ui.document:getPageFromXPointer(v.page)
end end
v.text = "Page "..page.." "..v.notes.." @ "..v.datetime v.text = _("Page") .. " " .. page .. " " .. v.notes .. " @ " .. v.datetime
end end
local bm_menu = Menu:new{ local bm_menu = Menu:new{

View File

@ -108,7 +108,7 @@ function FileChooser:genItemTableFromPath(path)
-- exclude "." and ".." -- exclude "." and ".."
items = items - 2 items = items - 2
end end
local istr = items .. (items > 1 and _(" items") or _(" item")) local istr = util.template(items == 0 and _("0 items") or _("1 item") or items > 1 and _("%1 items"), items)
table.insert(item_table, { table.insert(item_table, {
text = dir.name.."/", text = dir.name.."/",
mandatory = istr, mandatory = istr,

View File

@ -24,6 +24,7 @@ local Input = require("device").input
local UIManager = require("ui/uimanager") local UIManager = require("ui/uimanager")
local RenderText = require("ui/rendertext") local RenderText = require("ui/rendertext")
local InfoMessage = require("ui/widget/infomessage") local InfoMessage = require("ui/widget/infomessage")
local util = require("ffi/util")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local Blitbuffer = require("ffi/blitbuffer") local Blitbuffer = require("ffi/blitbuffer")
local _ = require("gettext") local _ = require("gettext")
@ -631,7 +632,7 @@ function Menu:updateItems(select_number)
self.item_group[select_number]:onFocus() self.item_group[select_number]:onFocus()
end end
-- update page information -- update page information
self.page_info_text.text = _("page ")..self.page.."/"..self.page_num self.page_info_text.text = util.template(_("page %1 of %2"), self.page, self.page_num)
self.page_info_left_chev:showHide(self.page_num > 1) self.page_info_left_chev:showHide(self.page_num > 1)
self.page_info_right_chev:showHide(self.page_num > 1) self.page_info_right_chev:showHide(self.page_num > 1)
self.page_info_first_chev:showHide(self.page_num > 2) self.page_info_first_chev:showHide(self.page_num > 2)

View File

@ -18,6 +18,7 @@ local Device = require("device")
local Screen = require("device").screen local Screen = require("device").screen
local Geom = require("ui/geometry") local Geom = require("ui/geometry")
local Font = require("ui/font") local Font = require("ui/font")
local util = require("ffi/util
local DEBUG = require("dbg") local DEBUG = require("dbg")
local _ = require("gettext") local _ = require("gettext")
local Blitbuffer = require("ffi/blitbuffer") local Blitbuffer = require("ffi/blitbuffer")
@ -451,7 +452,7 @@ function TouchMenu:updateItems()
table.insert(self.item_group, VerticalSpan:new{width = Screen:scaleByDPI(2)}) table.insert(self.item_group, VerticalSpan:new{width = Screen:scaleByDPI(2)})
table.insert(self.item_group, self.footer) table.insert(self.item_group, self.footer)
self.page_info_text.text = _("Page ")..self.page.."/"..self.page_num self.page_info_text.text = util.template(_("Page %1 of %2"), self.page, self.page_num)
self.page_info_left_chev:showHide(self.page_num > 1) self.page_info_left_chev:showHide(self.page_num > 1)
self.page_info_right_chev:showHide(self.page_num > 1) self.page_info_right_chev:showHide(self.page_num > 1)
self.page_info_left_chev:enableDisable(self.page > 1) self.page_info_left_chev:enableDisable(self.page > 1)