mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user