-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
取消阿里云的地域,实用性不是很大;
- Loading branch information
Showing
4 changed files
with
101 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import ( | |
"gui.subtitle/src/srv/mt/tencent" | ||
"gui.subtitle/src/srv/mt/youdao" | ||
"gui.subtitle/src/util/lang" | ||
"gui.subtitle/src/util/region" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
|
@@ -52,15 +53,14 @@ func (aw *AppWindow) newMainWindow() error { | |
|
||
var aLiIdEdit *walk.TextEdit | ||
var aLiKeyEdit *walk.TextEdit | ||
var aLiLocationEdit *walk.TextEdit | ||
|
||
var bdIdEdit *walk.TextEdit | ||
var bdKeyEdit *walk.TextEdit | ||
var bdApiVersionComboBox *walk.ComboBox | ||
|
||
var tencentIdEdit *walk.TextEdit | ||
var tencentKeyEdit *walk.TextEdit | ||
var tencentRegionEdit *walk.TextEdit | ||
var tencentRegionComboBox *walk.ComboBox | ||
|
||
var fromLanguageComboBox *walk.ComboBox | ||
var toLanguageComboBox *walk.ComboBox | ||
|
@@ -82,7 +82,7 @@ func (aw *AppWindow) newMainWindow() error { | |
Layout: VBox{}, | ||
Children: []Widget{ | ||
Label{Text: "***** 译名 *****", Alignment: AlignHCenterVCenter, Font: Font{Bold: true, PointSize: 10}}, | ||
Label{Text: "版本号: 1.1.8 作者: speauty 邮箱: [email protected]", Alignment: AlignHCenterVCenter}, | ||
Label{Text: "版本号: 1.1.9 作者: speauty 邮箱: [email protected]", Alignment: AlignHCenterVCenter}, | ||
GroupBox{ | ||
Layout: HBox{}, | ||
Children: []Widget{ | ||
|
@@ -98,8 +98,8 @@ func (aw *AppWindow) newMainWindow() error { | |
}, | ||
}, | ||
GroupBox{ | ||
MinSize: Size{Height: 110}, | ||
MaxSize: Size{Height: 110}, | ||
MinSize: Size{Height: 80}, | ||
MaxSize: Size{Height: 80}, | ||
Layout: VBox{}, | ||
Visible: Bind("mtEngineComboBox.CurrentIndex == 0"), | ||
Children: []Widget{ | ||
|
@@ -117,19 +117,12 @@ func (aw *AppWindow) newMainWindow() error { | |
HSpacer{}, | ||
}, | ||
}, | ||
HSplitter{ | ||
Children: []Widget{ | ||
Label{Text: "访问地域", ToolTipText: "AccessKeySecret"}, | ||
TextEdit{AssignTo: &aLiLocationEdit}, | ||
HSpacer{}, | ||
}, | ||
}, | ||
VSpacer{}, | ||
}, | ||
}, | ||
GroupBox{ | ||
MinSize: Size{Height: 110}, | ||
MaxSize: Size{Height: 110}, | ||
MinSize: Size{Height: 100}, | ||
MaxSize: Size{Height: 100}, | ||
Layout: VBox{}, | ||
Visible: Bind("mtEngineComboBox.CurrentIndex == 1"), | ||
Children: []Widget{ | ||
|
@@ -172,8 +165,8 @@ func (aw *AppWindow) newMainWindow() error { | |
}, | ||
}, | ||
GroupBox{ | ||
MinSize: Size{Height: 110}, | ||
MaxSize: Size{Height: 110}, | ||
MinSize: Size{Height: 100}, | ||
MaxSize: Size{Height: 100}, | ||
Layout: VBox{}, | ||
Visible: Bind(fmt.Sprintf("mtEngineComboBox.CurrentIndex == %d", mt.EngineTencent)), | ||
Children: []Widget{ | ||
|
@@ -193,8 +186,13 @@ func (aw *AppWindow) newMainWindow() error { | |
}, | ||
HSplitter{ | ||
Children: []Widget{ | ||
Label{Text: "访问地域", ToolTipText: "AccessKeySecret"}, | ||
TextEdit{AssignTo: &tencentRegionEdit}, | ||
Label{Text: "访问地域"}, | ||
ComboBox{ | ||
MinSize: Size{Width: 40}, MaxSize: Size{Width: 40}, | ||
AssignTo: &tencentRegionComboBox, | ||
Model: region.T_AP_BeiJing.GetZhMaps(mt.IdTencent), | ||
CurrentIndex: region.T_AP_BeiJing.ToInt(), | ||
}, | ||
HSpacer{}, | ||
}, | ||
}, | ||
|
@@ -386,7 +384,7 @@ func (aw *AppWindow) newMainWindow() error { | |
var cfg interface{} | ||
|
||
if currentMTEngine == mt.EngineALiYun { | ||
cfg = &aliyun.Cfg{AccessKeyId: aLiIdEdit.Text(), AccessKeySecret: aLiKeyEdit.Text(), Location: aLiLocationEdit.Text()} | ||
cfg = &aliyun.Cfg{AccessKeyId: aLiIdEdit.Text(), AccessKeySecret: aLiKeyEdit.Text()} | ||
mtEngine = new(aliyun.ALiMT) | ||
} else if currentMTEngine == mt.EngineBaiDu { | ||
cfg = &bd.Cfg{AppId: bdIdEdit.Text(), AppSecret: bdKeyEdit.Text()} | ||
|
@@ -395,7 +393,7 @@ func (aw *AppWindow) newMainWindow() error { | |
} else if currentMTEngine == mt.EngineYouDao { | ||
mtEngine = new(youdao.MT) | ||
} else if currentMTEngine == mt.EngineTencent { | ||
cfg = &tencent.Cfg{SecretId: tencentIdEdit.Text(), SecretKey: tencentKeyEdit.Text(), Region: tencentRegionEdit.Text()} | ||
cfg = &tencent.Cfg{SecretId: tencentIdEdit.Text(), SecretKey: tencentKeyEdit.Text(), Region: region.T_AP_BeiJing.FromInt(tencentRegionComboBox.CurrentIndex()).GetEn(mt.IdTencent)} | ||
mtEngine = new(tencent.MT) | ||
} else { | ||
walk.MsgBox(aw, "提示", fmt.Sprintf("当前翻译引擎[%s]暂未接入, 尽情期待", currentMTEngine.GetZH()), walk.MsgBoxIconWarning) | ||
|
@@ -429,12 +427,12 @@ func (aw *AppWindow) newMainWindow() error { | |
}, | ||
TextEdit{ | ||
AssignTo: &stateLabel, Visible: false, ReadOnly: true, VScroll: true, | ||
MinSize: Size{Height: 40}, MaxSize: Size{Height: 40}, | ||
MinSize: Size{Height: 40, Width: 80}, MaxSize: Size{Height: 40, Width: 80}, | ||
Font: Font{PointSize: 8}, | ||
}, | ||
TextEdit{ | ||
Visible: false, ReadOnly: true, VScroll: true, | ||
AssignTo: &logLabel, MinSize: Size{Height: 120, Width: 100}, MaxSize: Size{Height: 120, Width: 100}, | ||
AssignTo: &logLabel, MinSize: Size{Height: 120, Width: 80}, MaxSize: Size{Height: 120, Width: 80}, | ||
}, | ||
|
||
VSpacer{}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package region | ||
|
||
import ( | ||
"gui.subtitle/src/srv/mt" | ||
) | ||
|
||
type Region int | ||
|
||
func (r Region) FromInt(num int) Region { | ||
return Region(num) | ||
} | ||
|
||
func (r Region) ToInt() int { | ||
return int(r) | ||
} | ||
|
||
func (r Region) GetZh(id mt.Id) string { | ||
switch id { | ||
case mt.IdTencent: | ||
return tencentZHMaps[r] | ||
default: | ||
return "" | ||
} | ||
} | ||
|
||
func (r Region) GetZhMaps(id mt.Id) []string { | ||
switch id { | ||
case mt.IdTencent: | ||
return tencentZHMaps | ||
default: | ||
return []string{} | ||
} | ||
} | ||
|
||
func (r Region) GetEn(id mt.Id) string { | ||
switch id { | ||
case mt.IdTencent: | ||
return tencentENMaps[r] | ||
default: | ||
return "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package region | ||
|
||
const ( | ||
T_AP_BeiJing Region = iota | ||
T_AP_ChengDu | ||
T_AP_ChongQing | ||
T_AP_GuangZhou | ||
T_AP_ShangHai | ||
T_AP_ShangHai_FSI | ||
T_AP_ShenZhen_FSI | ||
T_AP_HongKong | ||
T_AP_Mumbai | ||
T_AP_Seoul | ||
T_AP_Bangkok | ||
T_AP_Singapore | ||
T_AP_Tokyo | ||
T_AP_EU_Frankfurt | ||
T_AP_NA_Ashburn | ||
T_AP_Siliconvalley | ||
T_AP_Torronto | ||
) | ||
|
||
var ( | ||
tencentZHMaps = []string{ | ||
"华北地区-北京", "西南地区-成都", "西南地区-重庆", "华南地区-广州", "华东地区-上海", | ||
"华东地区-上海金融", "华南地区-深圳金融", "港澳台地区-中国香港", | ||
"亚太南部-孟买", "亚太东北-首尔", "亚太东南-曼谷", "亚太东南-新加坡", "亚太东北-东京", | ||
"欧洲地区-法兰克福", "美国东部-弗吉尼亚", "美国西部-硅谷", "北美地区-多伦多", | ||
} | ||
|
||
tencentENMaps = []string{ | ||
"ap-beijing", "ap-chengdu", "ap-chongqing", "ap-guangzhou", "ap-shanghai", | ||
"ap-shanghai-fsi", "ap-shenzhen-fsi", "ap-hongkong", | ||
"ap-mumbai", "ap-seoul", "ap-bangkok", "ap-singapore", "ap-tokyo", | ||
"eu-frankfurt", "na-ashburn", "na-siliconvalley", "na-toronto", | ||
} | ||
) |