translator: use annotations

reviewable/pr11563/r5
hius07 2 months ago committed by GitHub
parent f94e3fc20e
commit 3781be1317
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -503,14 +503,14 @@ Show translated text in TextViewer, with alternate translations
@string source_lang[opt="auto"] (`"en"`, `"fr"`, ``) or `"auto"` to auto-detect source language @string source_lang[opt="auto"] (`"en"`, `"fr"`, ``) or `"auto"` to auto-detect source language
@string target_lang[opt] (`"en"`, `"fr"`, ``) @string target_lang[opt] (`"en"`, `"fr"`, ``)
--]] --]]
function Translator:showTranslation(text, detailed_view, source_lang, target_lang, from_highlight, page, index) function Translator:showTranslation(text, detailed_view, source_lang, target_lang, from_highlight, index)
if Device:hasClipboard() then if Device:hasClipboard() then
Device.input.setClipboardText(text) Device.input.setClipboardText(text)
end end
local NetworkMgr = require("ui/network/manager") local NetworkMgr = require("ui/network/manager")
if NetworkMgr:willRerunWhenOnline(function() if NetworkMgr:willRerunWhenOnline(function()
self:showTranslation(text, detailed_view, source_lang, target_lang, from_highlight, page, index) self:showTranslation(text, detailed_view, source_lang, target_lang, from_highlight, index)
end) then end) then
return return
end end
@ -519,11 +519,11 @@ function Translator:showTranslation(text, detailed_view, source_lang, target_lan
-- translation service query. -- translation service query.
local Trapper = require("ui/trapper") local Trapper = require("ui/trapper")
Trapper:wrap(function() Trapper:wrap(function()
self:_showTranslation(text, detailed_view, source_lang, target_lang, from_highlight, page, index) self:_showTranslation(text, detailed_view, source_lang, target_lang, from_highlight, index)
end) end)
end end
function Translator:_showTranslation(text, detailed_view, source_lang, target_lang, from_highlight, page, index) function Translator:_showTranslation(text, detailed_view, source_lang, target_lang, from_highlight, index)
if not target_lang then if not target_lang then
target_lang = self:getTargetLanguage() target_lang = self:getTargetLanguage()
end end
@ -632,8 +632,8 @@ function Translator:_showTranslation(text, detailed_view, source_lang, target_la
UIManager:close(textviewer) UIManager:close(textviewer)
UIManager:close(ui.highlight.highlight_dialog) UIManager:close(ui.highlight.highlight_dialog)
ui.highlight.highlight_dialog = nil ui.highlight.highlight_dialog = nil
if page then if index then
ui.highlight:editHighlight(page, index, false, text_main) ui.highlight:editHighlight(index, false, text_main)
else else
ui.highlight:addNote(text_main) ui.highlight:addNote(text_main)
end end
@ -645,8 +645,8 @@ function Translator:_showTranslation(text, detailed_view, source_lang, target_la
UIManager:close(textviewer) UIManager:close(textviewer)
UIManager:close(ui.highlight.highlight_dialog) UIManager:close(ui.highlight.highlight_dialog)
ui.highlight.highlight_dialog = nil ui.highlight.highlight_dialog = nil
if page then if index then
ui.highlight:editHighlight(page, index, false, text_all) ui.highlight:editHighlight(index, false, text_all)
else else
ui.highlight:addNote(text_all) ui.highlight:addNote(text_all)
end end

Loading…
Cancel
Save