diff --git a/README_zh.md b/README_zh.md index c0221f4..1fc2893 100644 --- a/README_zh.md +++ b/README_zh.md @@ -4,7 +4,7 @@ [English](README.md) -![image](assets/show_win.png) +![image](assets/show_win_zh.png) ## 功能展示 diff --git a/assets/show_win.png b/assets/show_win.png index debcc02..c51cd9b 100644 Binary files a/assets/show_win.png and b/assets/show_win.png differ diff --git a/assets/show_win_zh.png b/assets/show_win_zh.png new file mode 100644 index 0000000..f039577 Binary files /dev/null and b/assets/show_win_zh.png differ diff --git a/cmd/main.go b/cmd/main.go index 061d43c..9583a8f 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -15,7 +15,9 @@ func main() { jsonparser.EachKey(configs.Json, func(i int, bytes []byte, valueType jsonparser.ValueType, e error) { font, _ := jsonparser.GetString(bytes, "font") - _ = os.Setenv("FYNE_FONT", font) + if font != "" { + _ = os.Setenv("FYNE_FONT", font) + } theme, _ := jsonparser.GetString(bytes, "theme") _ = os.Setenv("FYNE_THEME", theme) scale, _ := jsonparser.GetString(bytes, "scale") @@ -23,7 +25,7 @@ func main() { }, []string{"const"}) main := app.NewWithID("Gopher") main.SetIcon(icon.Ico) - window := main.NewWindow("Gormat - Tool For Gopher") + window := main.NewWindow("Gormat") window.CenterOnScreen() window.Resize(fyne.Size{Width: 1200, Height: 720}) window.SetContent(_app.Container(main, window)) @@ -44,4 +46,5 @@ vendor/fyne.io/fyne/dialog/information.go:38 vendor/fyne.io/fyne/shortcut.go:43 vendor/fyne.io/fyne/widget/entry.go:526 vendor/fyne.io/fyne/widget/tabcontainer.go:390 +vendor/fyne.io/fyne/dialog/confirm.go:28 */ diff --git a/configs/init.go b/configs/init.go index c192b4c..e544b1b 100644 --- a/configs/init.go +++ b/configs/init.go @@ -7,33 +7,14 @@ package configs import ( + "github.com/buger/jsonparser" "io/ioutil" "os" + "strings" ) var ( - Json = []byte(`{ - "const": { - "font": "./miniHei.ttf", - "theme": "light", - "scale": "1.0" - }, - "sql2struct": { - "target_dir": "./models", - "auto_save": false, - "tags": [ - "gorm", - "json" - ], - "json_omitempty": false, - "exclude_tables": [], - "try_complete": true, - "tinyint2bool": true, - "sourceMap": [], - "reflect": "{\"tinyint\":\"int8\",\"smallint\":\"int16\",\"int\":\"int32\",\"bigint\":\"int64\",\"float\":\"float64\",\"double\":\"float64\",\"decimal\":\"float64\",\"char\":\"string\",\"varchar\":\"string\",\"text\":\"string\",\"mediumtext\":\"string\",\"longtext\":\"string\",\"time\":\"time.Time\",\"date\":\"time.Time\",\"datetime\":\"time.Time\",\"timestamp\":\"time.Time\",\"enum\":\"string\",\"set\":\"string\",\"blob\":\"string\"}", - "special": "{\"id\":\"uint\"}" - } -}`) + Json = []byte(`{"const":{"font":"./miniHei.ttf","theme":"light","scale":"1.0","language":"en"},"language":{"black":"黑色","light":"白色","default":"默认","effective after restart":"重启后生效","base":"基本","screen":"屏幕","language":"语言","rules":"规则","mapping":"映射","special":"特殊","sql to struct":"sql 转 struct","json to struct":"json 转 struct","edit link":"编辑连接","add link":"添加连接","bad link parameters":"错误的连接参数","Please input %s to delete the current group record":"请输入 %s 确认删除当前组记录","action":"操作","save ok":"保存成功","cancel":"取消","Please confirm to delete the current: %s ?":"确认删除当前 %s 连接记录吗?","no":"否","yes":"是","info":"信息","connection test":"测试连接","testing":"测试中","connection successful":"连接成功","the database can not be empty":"数据库名称不能为空","duplicate links":"重复的连接记录","engine":"引擎","host":"主机地址","port":"端口","user":"用户名","password":"密码","database":"数据库","table":"表结构","build only":"仅生成","build and include omitempty":"生成并包含omitempty","carriage return":"回车换行","auto save files":"保存文件","output folder":"输出文件夹","tags":"标签","exclusion table":"排除表","always execute":"始终执行","type conversion":"类型转换","the fields starting with is_ are automatically converted to bool":"is_开头字段自动转为bool","specified fields transformation":"指定字段转换","bool":"布尔值"},"sql2struct":{"target_dir":"./models","auto_save":false,"tags":["gorm","json"],"json_omitempty":false,"exclude_tables":[],"try_complete":true,"tinyint2bool":true,"sourceMap":[],"reflect":"{\"tinyint\":\"int8\",\"smallint\":\"int16\",\"int\":\"int32\",\"bigint\":\"int64\",\"float\":\"float64\",\"double\":\"float64\",\"decimal\":\"float64\",\"char\":\"string\",\"varchar\":\"string\",\"text\":\"string\",\"mediumtext\":\"string\",\"longtext\":\"string\",\"time\":\"time.Time\",\"date\":\"time.Time\",\"datetime\":\"time.Time\",\"timestamp\":\"time.Time\",\"enum\":\"string\",\"set\":\"string\",\"blob\":\"string\"}","special":"{\"id\":\"uint\"}"}}`) CustomFile = "./config.json" ) @@ -43,3 +24,19 @@ func init() { Json, _ = ioutil.ReadFile(CustomFile) } } + +func Text(key string, replace ...string) string { + l, _ := jsonparser.GetString(Json, "const", "language") + if l == "en" { + goto loop + } else if str, err := jsonparser.GetString(Json, "language", key); err != nil { + goto loop + } else { + key = str + } +loop: + if replace != nil { + return strings.Replace(key, "%s", replace[0], -1) + } + return key +} diff --git a/internal/app/container.go b/internal/app/container.go index df0929b..fc0fd4c 100644 --- a/internal/app/container.go +++ b/internal/app/container.go @@ -9,6 +9,7 @@ package app import ( "fyne.io/fyne" "fyne.io/fyne/layout" + "fyne.io/fyne/theme" "fyne.io/fyne/widget" "gormat/internal/app/sql2struct" "gormat/internal/pkg/icon" @@ -63,7 +64,7 @@ func Container(app fyne.App, win fyne.Window) *widget.TabContainer { c := widget.NewTabContainer( //widget.NewTabItemWithIcon("", icon.Home, WelcomeScreen()), widget.NewTabItemWithIcon("", icon.Store, s2sBox), - //widget.NewTabItemWithIcon("", theme.SettingsIcon(), SettingScreen(app, win)), + widget.NewTabItemWithIcon("", theme.SettingsIcon(), SettingScreen(app, win)), //widget.NewTabItemWithIcon("", icon.Daily, fyne.NewContainer()), //widget.NewTabItemWithIcon("", icon.Video, fyne.NewContainer()), ) diff --git a/internal/app/setting.go b/internal/app/setting.go index 468a024..da6695e 100644 --- a/internal/app/setting.go +++ b/internal/app/setting.go @@ -8,6 +8,7 @@ package app import ( "fyne.io/fyne" + "fyne.io/fyne/dialog" "fyne.io/fyne/layout" "fyne.io/fyne/theme" "fyne.io/fyne/widget" @@ -17,55 +18,83 @@ import ( ) func SettingScreen(app fyne.App, win fyne.Window) fyne.CanvasObject { - theMe := widget.NewRadio([]string{"黑色", "白色"}, func(s string) { + theMe := widget.NewRadio([]string{configs.Text("black"), configs.Text("light")}, func(s string) { switch s { - case "黑色": + case configs.Text("black"): app.Settings().SetTheme(theme.DarkTheme()) default: app.Settings().SetTheme(theme.LightTheme()) } }) + switch t, _ := jsonparser.GetString(configs.Json, "const", "theme"); t { - case "light": - theMe.SetSelected("白色") + case configs.Text("light"): + theMe.SetSelected(configs.Text("light")) default: - theMe.SetSelected("黑色") + theMe.SetSelected(configs.Text("black")) } theMe.Horizontal = true - dpi := widget.NewRadio([]string{"默认" /*"全屏",*/, "4K"}, func(s string) { - //win.SetFullScreen(false) + dpi := widget.NewRadio([]string{configs.Text("default"), "4K"}, func(s string) { + scale := "1.0" switch s { case "4K": - _ = os.Setenv("FYNE_SCALE", "2.0") - //case "全屏": - // win.SetFullScreen(true) - default: - _ = os.Setenv("FYNE_SCALE", "1.0") + scale = "2.0" + } + _ = os.Setenv("FYNE_SCALE", scale) + if data, err := jsonparser.Set(configs.Json, []byte("\""+scale+"\""), "const", "scale"); err == nil { + configs.Json = data } + dialog.ShowInformation(configs.Text("info"), configs.Text("effective after restart"), win) }) - switch scale, _ := jsonparser.GetFloat(configs.Json, "const", "scale"); scale { - case 1.0: - dpi.SetSelected("默认") - case 2.0: + switch scale, _ := jsonparser.GetString(configs.Json, "const", "scale"); scale { + case "1.0": + dpi.SetSelected(configs.Text("default")) + case "2.0": dpi.SetSelected("4K") } dpi.Horizontal = true + + language := widget.NewRadio([]string{"中文", "English"}, func(s string) { + //defer app.Settings().SetTheme(theme.LightTheme()) + lang := "en" + switch s { + case "中文": + lang = "zh" + } + if data, err := jsonparser.Set(configs.Json, []byte("\""+lang+"\""), "const", "language"); err == nil { + configs.Json = data + } + }) + l, _ := jsonparser.GetString(configs.Json, "const", "language") + if l == "zh" { + language.SetSelected("中文") + } else { + language.SetSelected("English") + } + language.Horizontal = true + return fyne.NewContainerWithLayout( layout.NewGridLayoutWithColumns(1), widget.NewTabContainer( - widget.NewTabItem("基本设置", widget.NewVBox( - widget.NewGroup("主题", + widget.NewTabItem(configs.Text("base"), widget.NewVBox( + //widget.NewGroup(configs.Text("theme")", + // fyne.NewContainerWithLayout( + // layout.NewHBoxLayout(), + // theMe, + // ), + //), + widget.NewGroup(configs.Text("screen"), fyne.NewContainerWithLayout( layout.NewHBoxLayout(), - theMe, + dpi, ), ), - widget.NewGroup("屏幕适配", + widget.NewGroup(configs.Text("language"), fyne.NewContainerWithLayout( layout.NewHBoxLayout(), - dpi, + language, ), ), )), diff --git a/internal/app/sql2struct/database.go b/internal/app/sql2struct/database.go index 5bfcf6e..497add6 100644 --- a/internal/app/sql2struct/database.go +++ b/internal/app/sql2struct/database.go @@ -45,8 +45,8 @@ func DataBase(window, currentWindow fyne.Window, ipBox *widget.TabContainer, opt db.SetText(currentLink.Db[dbIndex[1]]) } } - testDb := widget.NewHBox(widget.NewButton("测试连接", func() { - progressDialog := dialog.NewProgress("连接中", host.Text, currentWindow) + testDb := widget.NewHBox(widget.NewButton(configs.Text("connection test"), func() { + progressDialog := dialog.NewProgress(configs.Text("testing"), host.Text, currentWindow) go func() { num := 0.0 for num < 1.0 { @@ -69,7 +69,7 @@ func DataBase(window, currentWindow fyne.Window, ipBox *widget.TabContainer, opt if err != nil { dialog.ShowError(errors.New(err.Error()), currentWindow) } else { - dialog.ShowInformation("成功", "连接成功", currentWindow) + dialog.ShowInformation(configs.Text("info"), configs.Text("connection successful"), currentWindow) _ = Sql2struct.DB().Close() } })) @@ -79,7 +79,7 @@ func DataBase(window, currentWindow fyne.Window, ipBox *widget.TabContainer, opt }, OnSubmit: func() { if db.Text == "" { - dialog.ShowError(errors.New("数据库不能为空"), currentWindow) + dialog.ShowError(errors.New(configs.Text("the database can not be empty")), currentWindow) return } newDB := widget.NewTabItemWithIcon( @@ -113,7 +113,7 @@ func DataBase(window, currentWindow fyne.Window, ipBox *widget.TabContainer, opt if v.Host+":"+v.Port == host.Text+":"+port.Text { for _, curDb := range v.Db { if curDb == db.Text && v.Password == password.Text { - dialog.ShowError(errors.New("已存在相同的连接"), currentWindow) + dialog.ShowError(errors.New(configs.Text("duplicate links")), currentWindow) return } } @@ -167,12 +167,12 @@ func DataBase(window, currentWindow fyne.Window, ipBox *widget.TabContainer, opt } }, Items: []*widget.FormItem{ - {Text: "引擎", Widget: driver}, - {Text: "主机地址", Widget: host}, - {Text: "端口", Widget: port}, - {Text: "用户名", Widget: user}, - {Text: "密码", Widget: password}, - {Text: "数据库", Widget: db}, + {Text: configs.Text("engine"), Widget: driver}, + {Text: configs.Text("host"), Widget: host}, + {Text: configs.Text("port"), Widget: port}, + {Text: configs.Text("user"), Widget: user}, + {Text: configs.Text("password"), Widget: password}, + {Text: configs.Text("database"), Widget: db}, {Text: "", Widget: testDb}, }, } diff --git a/internal/app/sql2struct/init.go b/internal/app/sql2struct/init.go index 8f48e68..ee8ff49 100644 --- a/internal/app/sql2struct/init.go +++ b/internal/app/sql2struct/init.go @@ -10,6 +10,7 @@ import ( "go/ast" "go/parser" "go/token" + "gormat/configs" "gormat/internal/pkg/icon" "gormat/pkg/Sql2struct" "gormat/pkg/Sql2struct/quickly" @@ -95,7 +96,7 @@ func Screen(win fyne.Window, dbConf *Sql2struct.SourceMap) *fyne.Container { widget.NewLabel(err.Error()), ) } - tableBox := widget.NewGroupWithScroller("表结构") + tableBox := widget.NewGroupWithScroller(configs.Text("table")) if len(tables.Items) > 0 { go func() { currentTable <- &widget.TabItem{} diff --git a/internal/app/sql2struct/option.go b/internal/app/sql2struct/option.go index 722dde5..7f38221 100644 --- a/internal/app/sql2struct/option.go +++ b/internal/app/sql2struct/option.go @@ -22,14 +22,14 @@ import ( func Option(win fyne.Window, options *Sql2struct.SQL2Struct) fyne.Widget { targetDir := widget.NewEntry() targetDir.SetText(options.TargetDir) - autoSave := widget.NewRadio([]string{"是", "否"}, func(s string) { + autoSave := widget.NewRadio([]string{configs.Text("yes"), configs.Text("no")}, func(s string) { }) autoSave.Horizontal = true if options.AutoSave { - autoSave.SetSelected("是") + autoSave.SetSelected(configs.Text("yes")) } else { - autoSave.SetSelected("否") + autoSave.SetSelected(configs.Text("no")) } gorm := widget.NewCheck("gorm", func(bool) {}) @@ -41,13 +41,13 @@ func Option(win fyne.Window, options *Sql2struct.SQL2Struct) fyne.Widget { beegoOrm := widget.NewCheck("beegoOrm", func(bool) {}) beegoOrm.SetChecked(collection.Collect(options.Tags).Contains("beegoOrm")) - jsonType := widget.NewSelect([]string{"仅生成", "生成并包含 omitempty"}, func(s string) { + jsonType := widget.NewSelect([]string{configs.Text("build only"), configs.Text("build and include omitempty")}, func(s string) { }) if options.JsonOmitempty { - jsonType.SetSelected("生成并包含 omitempty") + jsonType.SetSelected(configs.Text("build and include omitempty")) } else { - jsonType.SetSelected("仅生成") + jsonType.SetSelected(configs.Text("build only")) } jsonT := widget.NewCheck("json", func(on bool) { @@ -61,16 +61,16 @@ func Option(win fyne.Window, options *Sql2struct.SQL2Struct) fyne.Widget { jsonT.SetChecked(!jsonType.Hidden) excludeTables := widget.NewMultiLineEntry() - excludeTables.SetPlaceHolder("多个数据表以回车换行") + excludeTables.SetPlaceHolder(configs.Text("carriage return")) excludeTables.SetText(strings.Join(options.ExcludeTables, "\n")) - tryComplete := widget.NewRadio([]string{"是", "否"}, func(s string) { + tryComplete := widget.NewRadio([]string{configs.Text("yes"), configs.Text("no")}, func(s string) { }) tryComplete.Horizontal = true if options.TryComplete { - tryComplete.SetSelected("是") + tryComplete.SetSelected(configs.Text("yes")) } else { - tryComplete.SetSelected("否") + tryComplete.SetSelected(configs.Text("no")) } return &widget.Form{ OnCancel: func() { @@ -78,7 +78,7 @@ func Option(win fyne.Window, options *Sql2struct.SQL2Struct) fyne.Widget { }, OnSubmit: func() { options.TargetDir = targetDir.Text - options.AutoSave = autoSave.Selected == "是" + options.AutoSave = autoSave.Selected == configs.Text("yes") options.Tags = []string{} if gorm.Checked { options.Tags = append(options.Tags, "gorm") @@ -92,28 +92,28 @@ func Option(win fyne.Window, options *Sql2struct.SQL2Struct) fyne.Widget { if jsonT.Checked { options.Tags = append(options.Tags, "json") } - options.JsonOmitempty = jsonType.Selected == "生成并包含 omitempty" + options.JsonOmitempty = jsonType.Selected == configs.Text("build and include omitempty") options.ExcludeTables = strings.Split(excludeTables.Text, "\n") - options.TryComplete = tryComplete.Selected == "是" + options.TryComplete = tryComplete.Selected == configs.Text("yes") jsons, _ := json.Marshal(options) if data, err := jsonparser.Set(configs.Json, jsons, "sql2struct"); err == nil { configs.Json = data - dialog.ShowInformation("成功", "保存成功", win) + dialog.ShowInformation(configs.Text("info"), configs.Text("save ok"), win) } else { dialog.ShowError(errors.New(err.Error()), win) } }, Items: []*widget.FormItem{ - {Text: "输出文件夹", Widget: targetDir}, - {Text: "自动存文件", Widget: autoSave}, - {Text: "标签选择", Widget: gorm}, + {Text: configs.Text("auto save files"), Widget: autoSave}, + {Text: configs.Text("output folder"), Widget: targetDir}, + {Text: configs.Text("tags"), Widget: gorm}, //{Text: "", Widget: beegoOrm}, {Text: "", Widget: xorm}, {Text: "", Widget: jsonT}, {Text: "", Widget: jsonType}, - {Text: "排除表", Widget: excludeTables}, - {Text: "始终执行", Widget: tryComplete}, + {Text: configs.Text("exclusion table"), Widget: excludeTables}, + {Text: configs.Text("always execute"), Widget: tryComplete}, }, } } diff --git a/internal/app/sql2struct/reflect.go b/internal/app/sql2struct/reflect.go index 4b0dc28..8232709 100644 --- a/internal/app/sql2struct/reflect.go +++ b/internal/app/sql2struct/reflect.go @@ -30,13 +30,13 @@ func Reflect(win fyne.Window, options *Sql2struct.SQL2Struct) fyne.Widget { jsons, _ := json.Marshal(options) if data, err := jsonparser.Set(configs.Json, jsons, "sql2struct"); err == nil { configs.Json = data - dialog.ShowInformation("成功", "保存成功", win) + dialog.ShowInformation(configs.Text("info"), configs.Text("save ok"), win) } else { dialog.ShowError(errors.New(err.Error()), win) } }, Items: []*widget.FormItem{ - {Text: "数据类型转换", Widget: dataType}, + {Text: configs.Text("type conversion"), Widget: dataType}, }, } } diff --git a/internal/app/sql2struct/special.go b/internal/app/sql2struct/special.go index c2483c0..e8f2ea9 100644 --- a/internal/app/sql2struct/special.go +++ b/internal/app/sql2struct/special.go @@ -21,7 +21,7 @@ import ( func Special(win fyne.Window, options *Sql2struct.SQL2Struct) fyne.Widget { specialData := widget.NewMultiLineEntry() specialData.SetText(strings.ReplaceAll(options.Special, ",", ",\n")) - autoBool := widget.NewCheck("is_开头的字段自动转bool", func(bool) {}) + autoBool := widget.NewCheck(configs.Text("the fields starting with is_ are automatically converted to bool"), func(bool) {}) autoBool.SetChecked(options.Tinyint2bool) return &widget.Form{ @@ -34,14 +34,14 @@ func Special(win fyne.Window, options *Sql2struct.SQL2Struct) fyne.Widget { jsons, _ := json.Marshal(options) if data, err := jsonparser.Set(configs.Json, jsons, "sql2struct"); err == nil { configs.Json = data - dialog.ShowInformation("成功", "保存成功", win) + dialog.ShowInformation(configs.Text("info"), configs.Text("save ok"), win) } else { dialog.ShowError(errors.New(err.Error()), win) } }, Items: []*widget.FormItem{ - {Text: "布尔选型", Widget: autoBool}, - {Text: "指定字段转型", Widget: specialData}, + {Text: configs.Text("bool"), Widget: autoBool}, + {Text: configs.Text("specified fields transformation"), Widget: specialData}, }, } } diff --git a/internal/app/toolbar.go b/internal/app/toolbar.go index 4ffafdc..01057c0 100644 --- a/internal/app/toolbar.go +++ b/internal/app/toolbar.go @@ -32,7 +32,7 @@ func ToolBar(win fyne.Window, ipBox *widget.TabContainer, options *Sql2struct.SQ } } } - w := fyne.CurrentApp().NewWindow("添加连接") + w := fyne.CurrentApp().NewWindow(configs.Text("add link")) w.SetContent(widget.NewScrollContainer( sql2struct.DataBase(win, w, ipBox, options, dbIndex)), ) @@ -41,11 +41,11 @@ func ToolBar(win fyne.Window, ipBox *widget.TabContainer, options *Sql2struct.SQ w.Show() }), widget.NewToolbarAction(icon.Option, func() { - w := fyne.CurrentApp().NewWindow("转换规则设置") + w := fyne.CurrentApp().NewWindow(configs.Text("rules")) setting := widget.NewTabContainer( - widget.NewTabItem("基本", sql2struct.Option(w, options)), - widget.NewTabItem("映射", sql2struct.Reflect(w, options)), - widget.NewTabItem("特殊转型", sql2struct.Special(w, options)), + widget.NewTabItem(configs.Text("base"), sql2struct.Option(w, options)), + widget.NewTabItem(configs.Text("mapping"), sql2struct.Reflect(w, options)), + widget.NewTabItem(configs.Text("special"), sql2struct.Special(w, options)), ) setting.SetTabLocation(widget.TabLocationLeading) w.SetContent(setting) @@ -54,7 +54,7 @@ func ToolBar(win fyne.Window, ipBox *widget.TabContainer, options *Sql2struct.SQ w.Show() }), widget.NewToolbarAction(icon.SQL, func() { - w := fyne.CurrentApp().NewWindow("Sql语句转Struct") + w := fyne.CurrentApp().NewWindow(configs.Text("sql to struct")) w.SetContent(fyne.NewContainerWithLayout( layout.NewGridLayout(1), widget.NewScrollContainer(sql2struct.QuickScreen()), @@ -64,7 +64,7 @@ func ToolBar(win fyne.Window, ipBox *widget.TabContainer, options *Sql2struct.SQ w.Show() }), widget.NewToolbarAction(icon.JSON, func() { - w := fyne.CurrentApp().NewWindow("Json语句转Struct") + w := fyne.CurrentApp().NewWindow(configs.Text("json to struct")) w.SetContent(fyne.NewContainerWithLayout( layout.NewGridLayout(1), widget.NewScrollContainer(json2struct.Screen()), @@ -99,7 +99,7 @@ func ToolBar(win fyne.Window, ipBox *widget.TabContainer, options *Sql2struct.SQ } dbBox := ipBox.CurrentTab().Content.(*widget.TabContainer) win.Canvas().Refresh(dbBox) - w := fyne.CurrentApp().NewWindow("编辑连接") + w := fyne.CurrentApp().NewWindow(configs.Text("edit link")) sourceMap := options.SourceMap var dbIndex []int for k, v := range sourceMap { @@ -114,7 +114,7 @@ func ToolBar(win fyne.Window, ipBox *widget.TabContainer, options *Sql2struct.SQ } loop: if dbIndex == nil { - w.SetContent(widget.NewLabelWithStyle(`错误的连接参数`, fyne.TextAlignCenter, fyne.TextStyle{Bold: true})) + w.SetContent(widget.NewLabelWithStyle(configs.Text("bad link parameters"), fyne.TextAlignCenter, fyne.TextStyle{Bold: true})) } else { w.SetContent(widget.NewScrollContainer( sql2struct.DataBase(win, w, ipBox, options, dbIndex))) @@ -128,7 +128,7 @@ func ToolBar(win fyne.Window, ipBox *widget.TabContainer, options *Sql2struct.SQ return } content := widget.NewEntry() - content.SetPlaceHolder("请输入 " + ipBox.CurrentTab().Text + " 确认删除当前组记录") + content.SetPlaceHolder(configs.Text("Please input %s to delete the current group record", ipBox.CurrentTab().Text)) content.OnChanged = func(text string) { defer ipBox.SelectTabIndex(ipBox.CurrentTabIndex()) if text == ipBox.CurrentTab().Text { @@ -142,7 +142,7 @@ func ToolBar(win fyne.Window, ipBox *widget.TabContainer, options *Sql2struct.SQ jsons, _ := json.Marshal(options) if data, err := jsonparser.Set(configs.Json, jsons, "sql2struct"); err == nil { configs.Json = data - dialog.ShowInformation("操作", "保存成功", win) + dialog.ShowInformation(configs.Text("action"), configs.Text("save ok"), win) ipBox.RemoveIndex(ipBox.CurrentTabIndex()) if ipBox.CurrentTabIndex()-1 < 0 { if len(ipBox.Items) == 0 { @@ -156,14 +156,14 @@ func ToolBar(win fyne.Window, ipBox *widget.TabContainer, options *Sql2struct.SQ } } } - dialog.ShowCustom("操作", "取消", content, win) + dialog.ShowCustom(configs.Text("action"), configs.Text("cancel"), content, win) }), widget.NewToolbarAction(icon.Delete, func() { if ipBox.Items == nil { return } dbBox := ipBox.CurrentTab().Content.(*widget.TabContainer) - cnf := dialog.NewConfirm("操作", "确定删除当前 "+dbBox.CurrentTab().Text+" 库连接记录?", func(isDelete bool) { + cnf := dialog.NewConfirm(configs.Text("action"), configs.Text("Please confirm to delete the current: %s ?", dbBox.CurrentTab().Text), func(isDelete bool) { if isDelete { sourceMap := options.SourceMap for k, v := range sourceMap { @@ -207,8 +207,8 @@ func ToolBar(win fyne.Window, ipBox *widget.TabContainer, options *Sql2struct.SQ } } }, win) - cnf.SetDismissText("否") - cnf.SetConfirmText("是") + cnf.SetDismissText(configs.Text("no")) + cnf.SetConfirmText(configs.Text("yes")) cnf.Show() }), widget.NewToolbarSpacer(), diff --git a/vendor/fyne.io/fyne/dialog/confirm.go b/vendor/fyne.io/fyne/dialog/confirm.go index dfd9f36..f09e43b 100644 --- a/vendor/fyne.io/fyne/dialog/confirm.go +++ b/vendor/fyne.io/fyne/dialog/confirm.go @@ -25,12 +25,12 @@ func (d *ConfirmDialog) SetConfirmText(label string) { func NewConfirm(title, message string, callback func(bool), parent fyne.Window) *ConfirmDialog { d := newDialog(title, message, theme.QuestionIcon(), callback, parent) - d.dismiss = &widget.Button{Text: "No", Icon: theme.CancelIcon(), + d.dismiss = &widget.Button{Text: "No", /* Icon: theme.CancelIcon(),*/ OnTapped: func() { d.response <- false }, } - confirm := &widget.Button{Text: "Yes", Icon: theme.ConfirmIcon(), Style: widget.PrimaryButton, + confirm := &widget.Button{Text: "Yes", /*Icon: theme.ConfirmIcon(),*/ Style: widget.PrimaryButton, OnTapped: func() { d.response <- true }, diff --git a/vendor/fyne.io/fyne/dialog/information.go b/vendor/fyne.io/fyne/dialog/information.go index b724a52..c1a52a3 100644 --- a/vendor/fyne.io/fyne/dialog/information.go +++ b/vendor/fyne.io/fyne/dialog/information.go @@ -9,7 +9,7 @@ import ( func createTextDialog(title, message string, icon fyne.Resource, parent fyne.Window) Dialog { d := newDialog(title, message, icon, nil, parent) - d.dismiss = &widget.Button{Text: "确定", + d.dismiss = &widget.Button{Text: "OK", OnTapped: func() { d.response <- false }, @@ -35,5 +35,5 @@ func ShowInformation(title, message string, parent fyne.Window) { // ShowError shows a dialog over the specified window for an application // error. The title and message are extracted from the provided error. func ShowError(err error, parent fyne.Window) { - createTextDialog("错误", err.Error(), theme.WarningIcon(), parent).Show() + createTextDialog("Error", err.Error(), theme.WarningIcon(), parent).Show() } diff --git a/vendor/fyne.io/fyne/shortcut.go b/vendor/fyne.io/fyne/shortcut.go index e0ac0c9..38e8a98 100644 --- a/vendor/fyne.io/fyne/shortcut.go +++ b/vendor/fyne.io/fyne/shortcut.go @@ -42,7 +42,7 @@ type ShortcutPaste struct { // ShortcutName returns the shortcut name func (se *ShortcutPaste) ShortcutName() string { - return "粘贴" + return "Paste" } // ShortcutCopy describes a shortcut copy action. @@ -52,7 +52,7 @@ type ShortcutCopy struct { // ShortcutName returns the shortcut name func (se *ShortcutCopy) ShortcutName() string { - return "复制" + return "Copy" } // ShortcutCut describes a shortcut cut action. @@ -62,7 +62,7 @@ type ShortcutCut struct { // ShortcutName returns the shortcut name func (se *ShortcutCut) ShortcutName() string { - return "剪切" + return "Cut" } // ShortcutSelectAll describes a shortcut selectAll action. @@ -70,5 +70,5 @@ type ShortcutSelectAll struct{} // ShortcutName returns the shortcut name func (se *ShortcutSelectAll) ShortcutName() string { - return "选择全部" + return "SelectAll" } diff --git a/vendor/fyne.io/fyne/widget/entry.go b/vendor/fyne.io/fyne/widget/entry.go index 03f197e..664a664 100644 --- a/vendor/fyne.io/fyne/widget/entry.go +++ b/vendor/fyne.io/fyne/widget/entry.go @@ -524,19 +524,19 @@ func (e *Entry) selectAll() { // // Opens the PopUpMenu with `Paste` item to paste text from the clipboard. func (e *Entry) TappedSecondary(pe *fyne.PointEvent) { - cutItem := fyne.NewMenuItem("剪切", func() { + cutItem := fyne.NewMenuItem("Cut", func() { clipboard := fyne.CurrentApp().Driver().AllWindows()[0].Clipboard() e.cutToClipboard(clipboard) }) - copyItem := fyne.NewMenuItem("复制", func() { + copyItem := fyne.NewMenuItem("Copy", func() { clipboard := fyne.CurrentApp().Driver().AllWindows()[0].Clipboard() e.copyToClipboard(clipboard) }) - pasteItem := fyne.NewMenuItem("粘贴", func() { + pasteItem := fyne.NewMenuItem("Paste", func() { clipboard := fyne.CurrentApp().Driver().AllWindows()[0].Clipboard() e.pasteFromClipboard(clipboard) }) - selectAllItem := fyne.NewMenuItem("选择全部", e.selectAll) + selectAllItem := fyne.NewMenuItem("Select all", e.selectAll) super := e.super() entryPos := fyne.CurrentApp().Driver().AbsolutePositionForObject(super) diff --git a/vendor/fyne.io/fyne/widget/form.go b/vendor/fyne.io/fyne/widget/form.go index ba813d5..39052b2 100644 --- a/vendor/fyne.io/fyne/widget/form.go +++ b/vendor/fyne.io/fyne/widget/form.go @@ -4,7 +4,6 @@ import ( "fyne.io/fyne" "fyne.io/fyne/internal/cache" "fyne.io/fyne/layout" - "fyne.io/fyne/theme" ) // FormItem provides the details for a row in a form @@ -85,10 +84,10 @@ func (f *Form) CreateRenderer() fyne.WidgetRenderer { buttons := NewHBox(layout.NewSpacer()) if f.OnCancel != nil { - buttons.Append(NewButtonWithIcon("取消", theme.CancelIcon(), f.OnCancel)) + buttons.Append(NewButton("Cancel", f.OnCancel)) } if f.OnSubmit != nil { - submit := NewButtonWithIcon("保存", theme.ConfirmIcon(), f.OnSubmit) + submit := NewButton("Submit", f.OnSubmit) submit.Style = PrimaryButton buttons.Append(submit) diff --git a/vendor/github.com/buger/jsonparser/Dockerfile b/vendor/github.com/buger/jsonparser/Dockerfile deleted file mode 100644 index 37fc9fd..0000000 --- a/vendor/github.com/buger/jsonparser/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM golang:1.6 - -RUN go get github.com/Jeffail/gabs -RUN go get github.com/bitly/go-simplejson -RUN go get github.com/pquerna/ffjson -RUN go get github.com/antonholmquist/jason -RUN go get github.com/mreiferson/go-ujson -RUN go get -tags=unsafe -u github.com/ugorji/go/codec -RUN go get github.com/mailru/easyjson - -WORKDIR /go/src/github.com/buger/jsonparser -ADD . /go/src/github.com/buger/jsonparser \ No newline at end of file