From 5012fb79d3fb107c95daa454255061cc274496a3 Mon Sep 17 00:00:00 2001 From: poire-z Date: Fri, 13 Jan 2017 00:58:17 +0100 Subject: [PATCH] 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. --- frontend/apps/reader/modules/readerhyphenation.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frontend/apps/reader/modules/readerhyphenation.lua b/frontend/apps/reader/modules/readerhyphenation.lua index 0920fe2db..d4c9fa5c7 100644 --- a/frontend/apps/reader/modules/readerhyphenation.lua +++ b/frontend/apps/reader/modules/readerhyphenation.lua @@ -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