v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-19 01:00:20 -07:00

update comment

This commit is contained in:
eeeXun 2022-10-23 22:30:03 +08:00
parent e313d326f3
commit 45da8702c6
4 changed files with 8 additions and 5 deletions

View File

@ -4,7 +4,7 @@ import (
"os" "os"
) )
// search XDG_CONFIG_HOME or $HOME/.config // Search XDG_CONFIG_HOME or $HOME/.config
func configInit() { func configInit() {
var defaultConfigPath string var defaultConfigPath string
@ -37,6 +37,7 @@ func configInit() {
translator.dstLang = config.GetString("destination.language") translator.dstLang = config.GetString("destination.language")
} }
// Check if need to modify config file when quit program
func updateConfig() { func updateConfig() {
changed := false changed := false

View File

@ -1,5 +1,6 @@
package main package main
// https://cloud.google.com/translate/docs/languages
var ( var (
Lang = []string{ Lang = []string{
"Afrikaans", "Afrikaans",

View File

@ -86,6 +86,7 @@ func (t *Translator) Translate(message string) (string, error) {
} }
return translated, nil return translated, nil
} }
return "", errors.New("Translation not found") return "", errors.New("Translation not found")
} }

8
ui.go
View File

@ -103,7 +103,7 @@ func updateAllColor() {
updateNonConfigColor() updateNonConfigColor()
} }
// update title and option // Update title and option
func updateTitle() { func updateTitle() {
srcBox.SetTitle(translator.srcLang) srcBox.SetTitle(translator.srcLang)
dstBox.SetTitle(translator.dstLang) dstBox.SetTitle(translator.dstLang)
@ -239,7 +239,7 @@ func translatePageHandler(event *tcell.EventKey) *tcell.EventKey {
} }
dstBox.SetText(src_text) dstBox.SetText(src_text)
case tcell.KeyCtrlO: case tcell.KeyCtrlO:
// play source sound // Play source sound
if translator.soundLock.Available() { if translator.soundLock.Available() {
message := srcBox.GetText() message := srcBox.GetText()
if len(message) > 0 { if len(message) > 0 {
@ -254,7 +254,7 @@ func translatePageHandler(event *tcell.EventKey) *tcell.EventKey {
} }
case tcell.KeyCtrlP: case tcell.KeyCtrlP:
// play destination sound // Play destination sound
if translator.soundLock.Available() { if translator.soundLock.Available() {
message := dstBox.GetText(false) message := dstBox.GetText(false)
if len(message) > 0 { if len(message) > 0 {
@ -268,7 +268,7 @@ func translatePageHandler(event *tcell.EventKey) *tcell.EventKey {
} }
} }
case tcell.KeyCtrlX: case tcell.KeyCtrlX:
// stop play sound // Stop play sound
translator.soundLock.stop = true translator.soundLock.stop = true
} }