style: use Trans.key instead of "Trans.key"

This commit is contained in:
JuanZoran
2023-03-12 11:23:29 +08:00
parent b05018e1bf
commit ded28b68bc
10 changed files with 70 additions and 68 deletions

View File

@@ -1,6 +1,9 @@
local M = {}
local M = {}
local baidu = require('Trans').conf.engines.baidu
local Trans = require('Trans')
local baidu = Trans.conf.keys.baidu
local app_id = baidu.app_id
local app_passwd = baidu.app_passwd
local salt = tostring(math.random(bit.lshift(1, 15)))
@@ -9,7 +12,8 @@ local uri = 'https://fanyi-api.baidu.com/api/trans/vip/translate'
function M.get_content(data)
local tmp = app_id .. data.str .. salt .. app_passwd
local sign = require('Trans.util.md5').sumhexa(tmp)
local sign = Trans.util.md5.sumhexa(tmp)
return {
q = data.str,
from = data.from,
@@ -51,7 +55,8 @@ function M.query(data)
data.trace = res
end
require('Trans.wrapper.curl').get(uri, {
Trans.wrapper.curl.get(uri, {
query = M.get_content(data),
callback = handle,
})

View File

@@ -1,10 +0,0 @@
return setmetatable({}, {
__index = function(t, k)
local res, engine = pcall(require, [[Trans.backend.]] .. k)
if not res then
error([[Fail to load backend: ]] .. k .. '\n ' .. engine)
end
t[k] = engine
return engine
end
})