getProps: centralize 2 (#10837)

Centralize and optimize handling document properties.
This commit is contained in:
hius07
2023-08-30 07:53:59 +03:00
committed by GitHub
parent 38d468f36c
commit 1ef7821b66
23 changed files with 189 additions and 239 deletions

View File

@@ -1436,15 +1436,6 @@ dbg:guard(ReaderHighlight, "translate",
"translate must not be called with nil selected_text!")
end)
function ReaderHighlight:getDocumentLanguage()
local doc_props = self.ui.doc_settings:readSetting("doc_props")
local doc_lang = doc_props and doc_props.language
if doc_lang == "" then
doc_lang = nil
end
return doc_lang
end
function ReaderHighlight:onTranslateText(text, page, index)
Translator:showTranslation(text, true, nil, nil, true, page, index)
end
@@ -1473,7 +1464,7 @@ function ReaderHighlight:onTranslateCurrentPage()
self.ui.document.configurable.text_wrap = is_reflow
end
if res and res.text then
Translator:showTranslation(res.text, false, self:getDocumentLanguage())
Translator:showTranslation(res.text, false, self.ui.doc_props.language)
end
end