Set hyphenation dict fallback with Hold

For documents without language defined in metadata (.txt, .html),
crengine would fallback to hardcoded English_US_hyphen_(Alan).pdb.
This allows for setting a different one.
pull/2490/head
poire-z 7 years ago committed by Qingping Hou
parent aa918c7773
commit 5012fb79d3

@ -2,6 +2,7 @@ local InputContainer = require("ui/widget/container/inputcontainer")
local UIManager = require("ui/uimanager")
local JSON = require("json")
local InfoMessage = require("ui/widget/infomessage")
local ConfirmBox = require("ui/widget/confirmbox")
local T = require("ffi/util").template
local _ = require("gettext")
local util = require("util")
@ -31,6 +32,14 @@ function ReaderHyphenation:init()
self.ui.document:setHyphDictionary(v.filename)
self.ui.toc:onUpdateToc()
end,
hold_callback = function()
UIManager:show(ConfirmBox:new{
text = T( _("Set fallback hyphenation to %1?"), v.name),
ok_callback = function()
G_reader_settings:saveSetting("hyph_alg_fallback", v.filename)
end,
})
end,
checked_func = function()
return v.filename == self.hyph_alg
end
@ -95,6 +104,9 @@ function ReaderHyphenation:onPreRenderDocument(config)
if not hyph_alg then
hyph_alg = self:getDictForLanguage(self.ui.document:getProps().language)
end
if not hyph_alg then
hyph_alg = G_reader_settings:readSetting("hyph_alg_fallback")
end
if hyph_alg then
self.ui.document:setHyphDictionary(hyph_alg)
end

Loading…
Cancel
Save