Docs: cosmetic updates and additions

* Content from wiki had some cosmetic leftover glitches
* Added/adapted some docs for other modules
This commit is contained in:
Frans de Jonge
2017-04-12 18:55:22 +02:00
committed by Qingping Hou
parent 5de8310aa6
commit c847d628e1
8 changed files with 102 additions and 74 deletions

View File

@@ -1,11 +1,12 @@
--[[--
This module translates text using Google Translate.
<http://translate.google.com/translate_a/t?client=z&ie=UTF-8&oe=UTF-8&hl=en&tl=en&text=hello>
--]]
local JSON = require("json")
local logger = require("logger")
--[[
-- Translate text using Google Translate.
-- http://translate.google.com/translate_a/t?client=z&ie=UTF-8&oe=UTF-8&hl=en&tl=en&text=hello
--]]
local Translator = {
trans_servers = {
"http://translate.google.cn",
@@ -27,8 +28,13 @@ function Translator:getTransServer()
return G_reader_settings:readSetting("trans_server") or self.trans_servers[1]
end
--[[
-- return decoded JSON table from translate server
--[[--
Returns decoded JSON table from translate server.
@string target_lang
@string source_lang
@string text
@treturn string result, or nil
--]]
function Translator:loadPage(target_lang, source_lang, text)
local socket = require('socket')
@@ -80,6 +86,12 @@ function Translator:loadPage(target_lang, source_lang, text)
end
end
--[[--
Tries to automatically detect language of `text`.
@string text
@treturn string lang (`"en"`, `"fr"`, `…`)
--]]
function Translator:detect(text)
local result = self:loadPage("en", nil, text)
if result then