mirror of
https://github.com/koreader/koreader
synced 2024-11-10 01:10:34 +00:00
add menu entry to lookup input word in dictionary
This should close #971.
This commit is contained in:
parent
12914a01f3
commit
506bf96379
@ -1,13 +1,30 @@
|
||||
local EventListener = require("ui/widget/eventlistener")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local DictQuickLookup = require("ui/widget/dictquicklookup")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Geom = require("ui/geometry")
|
||||
local Screen = require("ui/screen")
|
||||
local JSON = require("JSON")
|
||||
local DEBUG = require("dbg")
|
||||
local _ = require("gettext")
|
||||
|
||||
local ReaderDictionary = EventListener:new{}
|
||||
local ReaderDictionary = InputContainer:new{}
|
||||
|
||||
function ReaderDictionary:init()
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
end
|
||||
|
||||
function ReaderDictionary:addToMainMenu(tab_item_table)
|
||||
table.insert(tab_item_table.plugins, {
|
||||
text = _("Dictionary lookup"),
|
||||
tap_input = {
|
||||
title = _("Input word to lookup"),
|
||||
type = "text",
|
||||
callback = function(input)
|
||||
self:onLookupWord(input)
|
||||
end,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
function ReaderDictionary:onLookupWord(word, box, highlight)
|
||||
self.highlight = highlight
|
||||
|
@ -11,12 +11,17 @@ local DEBUG = require("dbg")
|
||||
local _ = require("gettext")
|
||||
|
||||
-- Wikipedia as a special dictionary
|
||||
local ReaderWikipedia = ReaderDictionary:new{
|
||||
local ReaderWikipedia = ReaderDictionary:extend{
|
||||
-- identify itself
|
||||
wiki = true,
|
||||
no_page = _("No wiki page found."),
|
||||
}
|
||||
|
||||
-- the super "class" ReaderDictionary has already registers a menu entry
|
||||
-- we should override the init function in ReaderWikipedia
|
||||
function ReaderWikipedia:init()
|
||||
end
|
||||
|
||||
function ReaderWikipedia:onLookupWikipedia(word, box)
|
||||
-- detect language of the text
|
||||
local ok, lang = pcall(Translator.detect, Translator, word)
|
||||
|
Loading…
Reference in New Issue
Block a user