Skip to content

Commit

Permalink
feat(engine-translate): 引入阿里云翻译;
Browse files Browse the repository at this point in the history
  • Loading branch information
speauty committed Apr 3, 2023
1 parent 198a98c commit 85b047f
Show file tree
Hide file tree
Showing 11 changed files with 297 additions and 52 deletions.
3 changes: 3 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"translator/menu"
"translator/page"
"translator/tst/tt_log"
"translator/tst/tt_translator/ali_cloud_mt"
"translator/tst/tt_translator/baidu"
"translator/tst/tt_translator/huawei_cloud_nlp"
"translator/tst/tt_translator/ling_va"
Expand All @@ -34,11 +35,13 @@ func main() {
baidu.GetInstance().Init(cfg.GetInstance().Baidu)
tencent_cloud_mt.GetInstance().Init(cfg.GetInstance().TencentCloudMT)
openapi_youdao.GetInstance().Init(cfg.GetInstance().OpenAPIYouDao)
ali_cloud_mt.GetInstance().Init(cfg.GetInstance().AliCloudMT)

domain.GetTranslators().Register(
huawei_cloud_nlp.GetInstance(),
youdao.GetInstance(), ling_va.GetInstance(), baidu.GetInstance(),
tencent_cloud_mt.GetInstance(), openapi_youdao.GetInstance(),
ali_cloud_mt.GetInstance(),
)

tt_ui.GetInstance().RegisterMenus(menu.GetInstance().GetMenus())
Expand Down
7 changes: 6 additions & 1 deletion cfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ huawei_cloud_nlp: # 华为云机器翻译
project_id: "" # 项目ID

ling_va:
data_id: "" # 数据ID
data_id: "3qnDcUVykFKnSC3cdRX2t" # 数据ID

baidu:
app_id: "" # 应用ID
Expand All @@ -18,3 +18,8 @@ tencent_cloud_mt: # 腾讯云机器翻译
openapi_youdao: # 有道智云翻译
app_key: "" # 应用ID
app_secret: "" # 应用密钥

ali_cloud_mt: # 阿里云翻译
ak_id: "" # 应用ID
ak_secret: "" # 应用密钥
region: "" # 区域
3 changes: 3 additions & 0 deletions cfg/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cfg
import (
"fmt"
"sync"
"translator/tst/tt_translator/ali_cloud_mt"
"translator/tst/tt_translator/baidu"
"translator/tst/tt_translator/huawei_cloud_nlp"
"translator/tst/tt_translator/ling_va"
Expand All @@ -26,6 +27,7 @@ func GetInstance() *Cfg {
apiCfg.Baidu = baidu.Cfg{}.Default()
apiCfg.TencentCloudMT = tencent_cloud_mt.Cfg{}.Default()
apiCfg.OpenAPIYouDao = openapi_youdao.Cfg{}.Default()
apiCfg.AliCloudMT = ali_cloud_mt.Cfg{}.Default()
})
return apiCfg
}
Expand All @@ -38,6 +40,7 @@ type Cfg struct {
Baidu *baidu.Cfg `mapstructure:"baidu"`
TencentCloudMT *tencent_cloud_mt.Cfg `mapstructure:"tencent_cloud_mt"`
OpenAPIYouDao *openapi_youdao.Cfg `mapstructure:"openapi_youdao"`
AliCloudMT *ali_cloud_mt.Cfg `mapstructure:"ali_cloud_mt"`
}

func (customC *Cfg) NewUITitle() string {
Expand Down
6 changes: 6 additions & 0 deletions cfg/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ func (customC *Cfg) Sync() error {
viper.Set("openapi_youdao.app_secret", customC.OpenAPIYouDao.AppSecret)
}

{ // sync ali_cloud_mt
viper.Set("ali_cloud_mt.ak_id", customC.AliCloudMT.AKId)
viper.Set("ali_cloud_mt.ak_secret", customC.AliCloudMT.AKSecret)
viper.Set("ali_cloud_mt.region", customC.AliCloudMT.Region)
}

if err := viper.WriteConfig(); err != nil {
return fmt.Errorf("写入配置失败, 错误: %s", err)
}
Expand Down
8 changes: 7 additions & 1 deletion const/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ huawei_cloud_nlp: # 华为云机器翻译
project_id: "" # 项目ID
ling_va:
data_id: "" # 数据ID
data_id: "3qnDcUVykFKnSC3cdRX2t" # 数据ID
baidu:
app_id: "" # 应用ID
Expand All @@ -33,5 +33,11 @@ tencent_cloud_mt: # 腾讯云机器翻译
openapi_youdao: # 有道智云翻译
app_key: "" # 应用ID
app_secret: "" # 应用密钥
ali_cloud_mt: # 阿里云翻译
ak_id: "" # 应用ID
ak_secret: "" # 应用密钥
region: "" # 区域
`
)
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module translator
go 1.19

require (
github.com/aliyun/alibaba-cloud-sdk-go v1.62.267
github.com/golang-module/carbon v1.7.3
github.com/google/go-querystring v1.1.0
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.34
Expand All @@ -12,24 +13,26 @@ require (
github.com/spf13/viper v1.15.0
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.628
github.com/twharmon/gouid v0.5.2
golang.org/x/crypto v0.7.0
)

require (
github.com/gobuffalo/envy v1.7.0 // indirect
github.com/gobuffalo/packd v0.3.0 // indirect
github.com/gobuffalo/packr v1.30.1 // indirect
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
github.com/joho/godotenv v1.3.0 // indirect
github.com/jonboulle/clockwork v0.3.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/lestrrat-go/strftime v1.0.6 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rogpeppe/go-internal v1.6.1 // indirect
go.mongodb.org/mongo-driver v1.11.2 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
gopkg.in/Knetic/govaluate.v3 v3.0.0 // indirect
)

Expand Down
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/aliyun/alibaba-cloud-sdk-go v1.62.267 h1:p0SMV+o/NLPeaIJYTnIwEvNQdLrOxQ97EFfo7pYkQpM=
github.com/aliyun/alibaba-cloud-sdk-go v1.62.267/go.mod h1:Api2AkmMgGaSUAhmk76oaFObkoeCPc/bKAqcyplPODs=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down Expand Up @@ -76,6 +78,7 @@ github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b
github.com/gobuffalo/packr v1.30.1 h1:hu1fuVR3fXEZR7rXNW3h8rqSML8EVAf6KNm0NKO/wKg=
github.com/gobuffalo/packr v1.30.1/go.mod h1:ljMyFO2EcrnzsHsN99cvbq055Y9OhRrIaviy289eRuk=
github.com/gobuffalo/packr/v2 v2.5.1/go.mod h1:8f9c96ITobJlPzI44jj+4tHnEKNt0xXWSVlXRN9X1Iw=
github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A=
github.com/golang-module/carbon v1.7.3 h1:p5mUZj7Tg62MblrkF7XEoxVPvhVs20N/kimqsZOQ+/U=
github.com/golang-module/carbon v1.7.3/go.mod h1:nUMnXq90Rv8a7h2+YOo2BGKS77Y0w/hMPm4/a8h19N8=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
Expand Down Expand Up @@ -146,10 +149,13 @@ github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.34/go.mod h1:BXgkXeyM6erEASLPH
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg=
github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
Expand Down Expand Up @@ -185,9 +191,12 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b h1:FfH+VrHHk6Lxt9HdVS0PXzSXFyS2NbZKXv33FYPol0A=
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b/go.mod h1:AC62GU6hc0BrNm+9RK9VSiwa/EUe1bkIeFORAMcHvJU=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
Expand Down Expand Up @@ -242,6 +251,10 @@ github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/twharmon/gouid v0.5.2 h1:fqFUx700Ishb4dZaXpRv95CGGGR1CBuCkjM0t62XAxw=
github.com/twharmon/gouid v0.5.2/go.mod h1:m1SyQo0sYYbukI1yNZ1WRk980fV2XWBuYGAtMo/AmQ8=
github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o=
github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg=
github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
Expand Down Expand Up @@ -585,6 +598,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.66.6/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
Expand Down
142 changes: 93 additions & 49 deletions page/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type Settings struct {
ptrTencentCloudMTSecretKey *walk.LineEdit
ptrOpenAPIYouDaoAppKey *walk.LineEdit
ptrOpenAPIYouDaoAppSecret *walk.LineEdit
ptrAliCloudMTAkId *walk.LineEdit
ptrAliCloudMTAkSecret *walk.LineEdit
ptrHuaweiCloudAKId *walk.LineEdit
ptrHuaweiCloudSKKey *walk.LineEdit
ptrHuaweiCloudAKProjectId *walk.LineEdit
Expand Down Expand Up @@ -126,6 +128,20 @@ func (customPage *Settings) GetWidget() Widget {
)),
).AppendZeroHSpacer().GetWidgets(),
)),
pack.TTGroupBox(pack.NewTTGroupBoxArgs(nil).SetTitle("阿里云翻译").SetLayoutVBox(false).SetWidgets(
pack.NewWidgetGroup().Append(
pack.TTComposite(pack.NewTTCompositeArgs(nil).SetLayoutHBox(true).SetWidgets(
pack.NewWidgetGroup().Append(
pack.TTLabel(pack.NewTTLabelArgs(nil).SetText("应用ID")),
pack.TTLineEdit(pack.NewLineEditWrapperArgs(&customPage.ptrAliCloudMTAkId).
SetText(cfg.GetInstance().AliCloudMT.AKId)),
pack.TTLabel(pack.NewTTLabelArgs(nil).SetText("应用密钥")),
pack.TTLineEdit(pack.NewLineEditWrapperArgs(&customPage.ptrAliCloudMTAkSecret).
SetText(cfg.GetInstance().AliCloudMT.AKSecret)),
).GetWidgets(),
)),
).AppendZeroHSpacer().GetWidgets(),
)),
pack.TTGroupBox(pack.NewTTGroupBoxArgs(nil).SetTitle("华为云翻译").SetLayoutVBox(false).SetWidgets(
pack.NewWidgetGroup().Append(
pack.TTComposite(pack.NewTTCompositeArgs(nil).SetLayoutHBox(true).SetWidgets(
Expand Down Expand Up @@ -159,64 +175,92 @@ func (customPage *Settings) Reset() {
}

func (customPage *Settings) eventSync() {
lingVADataId := customPage.ptrLingVADataId.Text()
baiduAppId := customPage.ptrBaiduAppId.Text()
baiduAppKey := customPage.ptrBaiduAppKey.Text()
tencentCloudMTSecretId := customPage.ptrTencentCloudMTSecretId.Text()
tencentCloudMTSecretKey := customPage.ptrTencentCloudMTSecretKey.Text()
openAPIYouDaoAppKey := customPage.ptrOpenAPIYouDaoAppKey.Text()
openAPIYouDaoAppSecret := customPage.ptrOpenAPIYouDaoAppSecret.Text()
huaweiCloudAKId := customPage.ptrHuaweiCloudAKId.Text()
huaweiCloudSKKey := customPage.ptrHuaweiCloudSKKey.Text()
huaweiCloudAKProjectId := customPage.ptrHuaweiCloudAKProjectId.Text()
huaweiCloudAKRegion := customPage.ptrHuaweiCloudAKRegion.Text()
cntModified := 0
if lingVADataId != cfg.GetInstance().LingVA.DataId {
cfg.GetInstance().LingVA.DataId = lingVADataId
cntModified++
}
if baiduAppId != cfg.GetInstance().Baidu.AppId {
cfg.GetInstance().Baidu.AppId = baiduAppId
cntModified++
}
if baiduAppKey != cfg.GetInstance().Baidu.AppKey {
cfg.GetInstance().Baidu.AppKey = baiduAppKey
cntModified++
}
if tencentCloudMTSecretId != cfg.GetInstance().TencentCloudMT.SecretId {
cfg.GetInstance().TencentCloudMT.SecretId = tencentCloudMTSecretId
cntModified++
}
if tencentCloudMTSecretKey != cfg.GetInstance().TencentCloudMT.SecretKey {
cfg.GetInstance().TencentCloudMT.SecretKey = tencentCloudMTSecretKey
cntModified++
}

if openAPIYouDaoAppKey != cfg.GetInstance().OpenAPIYouDao.AppKey {
cfg.GetInstance().OpenAPIYouDao.AppKey = openAPIYouDaoAppKey
cntModified++
{
lingVADataId := customPage.ptrLingVADataId.Text()
if lingVADataId != cfg.GetInstance().LingVA.DataId {
cfg.GetInstance().LingVA.DataId = lingVADataId
cntModified++
}
}
if openAPIYouDaoAppSecret != cfg.GetInstance().OpenAPIYouDao.AppSecret {
cfg.GetInstance().OpenAPIYouDao.AppSecret = openAPIYouDaoAppSecret
cntModified++

{
baiduAppId := customPage.ptrBaiduAppId.Text()
baiduAppKey := customPage.ptrBaiduAppKey.Text()
if baiduAppId != cfg.GetInstance().Baidu.AppId {
cfg.GetInstance().Baidu.AppId = baiduAppId
cntModified++
}
if baiduAppKey != cfg.GetInstance().Baidu.AppKey {
cfg.GetInstance().Baidu.AppKey = baiduAppKey
cntModified++
}
}

if huaweiCloudAKId != cfg.GetInstance().HuaweiCloudNlp.AKId {
cfg.GetInstance().HuaweiCloudNlp.AKId = huaweiCloudAKId
cntModified++
{
tencentCloudMTSecretId := customPage.ptrTencentCloudMTSecretId.Text()
tencentCloudMTSecretKey := customPage.ptrTencentCloudMTSecretKey.Text()
if tencentCloudMTSecretId != cfg.GetInstance().TencentCloudMT.SecretId {
cfg.GetInstance().TencentCloudMT.SecretId = tencentCloudMTSecretId
cntModified++
}
if tencentCloudMTSecretKey != cfg.GetInstance().TencentCloudMT.SecretKey {
cfg.GetInstance().TencentCloudMT.SecretKey = tencentCloudMTSecretKey
cntModified++
}
}
if huaweiCloudSKKey != cfg.GetInstance().HuaweiCloudNlp.SkKey {
cfg.GetInstance().HuaweiCloudNlp.SkKey = huaweiCloudSKKey
cntModified++

{
openAPIYouDaoAppKey := customPage.ptrOpenAPIYouDaoAppKey.Text()
openAPIYouDaoAppSecret := customPage.ptrOpenAPIYouDaoAppSecret.Text()
if openAPIYouDaoAppKey != cfg.GetInstance().OpenAPIYouDao.AppKey {
cfg.GetInstance().OpenAPIYouDao.AppKey = openAPIYouDaoAppKey
cntModified++
}
if openAPIYouDaoAppSecret != cfg.GetInstance().OpenAPIYouDao.AppSecret {
cfg.GetInstance().OpenAPIYouDao.AppSecret = openAPIYouDaoAppSecret
cntModified++
}
}
if huaweiCloudAKProjectId != cfg.GetInstance().HuaweiCloudNlp.ProjectId {
cfg.GetInstance().HuaweiCloudNlp.ProjectId = huaweiCloudAKProjectId
cntModified++

{
aliCloudMTAkId := customPage.ptrAliCloudMTAkId.Text()
aliCloudMTAkSecret := customPage.ptrAliCloudMTAkSecret.Text()
if aliCloudMTAkId != cfg.GetInstance().AliCloudMT.AKId {
cfg.GetInstance().AliCloudMT.AKId = aliCloudMTAkId
cntModified++
}
if aliCloudMTAkSecret != cfg.GetInstance().AliCloudMT.AKSecret {
cfg.GetInstance().AliCloudMT.AKSecret = aliCloudMTAkSecret
cntModified++
}
}
if huaweiCloudAKRegion != cfg.GetInstance().HuaweiCloudNlp.Region {
cfg.GetInstance().HuaweiCloudNlp.Region = huaweiCloudAKRegion
cntModified++

{
huaweiCloudAKId := customPage.ptrHuaweiCloudAKId.Text()
huaweiCloudSKKey := customPage.ptrHuaweiCloudSKKey.Text()
huaweiCloudAKProjectId := customPage.ptrHuaweiCloudAKProjectId.Text()
huaweiCloudAKRegion := customPage.ptrHuaweiCloudAKRegion.Text()

if huaweiCloudAKId != cfg.GetInstance().HuaweiCloudNlp.AKId {
cfg.GetInstance().HuaweiCloudNlp.AKId = huaweiCloudAKId
cntModified++
}
if huaweiCloudSKKey != cfg.GetInstance().HuaweiCloudNlp.SkKey {
cfg.GetInstance().HuaweiCloudNlp.SkKey = huaweiCloudSKKey
cntModified++
}
if huaweiCloudAKProjectId != cfg.GetInstance().HuaweiCloudNlp.ProjectId {
cfg.GetInstance().HuaweiCloudNlp.ProjectId = huaweiCloudAKProjectId
cntModified++
}
if huaweiCloudAKRegion != cfg.GetInstance().HuaweiCloudNlp.Region {
cfg.GetInstance().HuaweiCloudNlp.Region = huaweiCloudAKRegion
cntModified++
}
}

if cntModified == 0 {
msg.Info(customPage.mainWindow, "暂无配置需要同步")
return
Expand Down
13 changes: 13 additions & 0 deletions tst/tt_translator/ali_cloud_mt/cfg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ali_cloud_mt

type Cfg struct {
AKId string `mapstructure:"ak_id"`
AKSecret string `mapstructure:"ak_secret"`
Region string `mapstructure:"region"`
}

func (customC Cfg) Default() *Cfg {
return &Cfg{
AKId: "", AKSecret: "", Region: "",
}
}
14 changes: 14 additions & 0 deletions tst/tt_translator/ali_cloud_mt/lang.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package ali_cloud_mt

import "translator/tst/tt_translator"

var langSupported = []tt_translator.LangK{
{"zh", "中文"},
{"en", "英语"},
{"ja", "日语"},
{"ko", "韩语"},
{"ru", "俄语"},
{"fr", "法语"},
{"de", "德语"},
{"ar", "阿拉伯语"},
}
Loading

0 comments on commit 85b047f

Please sign in to comment.