diff --git a/googletranslate/languages.go b/googletranslate/languages.go index 159bcc4..b468e42 100644 --- a/googletranslate/languages.go +++ b/googletranslate/languages.go @@ -92,7 +92,7 @@ func ListLanguages() string { return langs } -func inLangList(code string) bool { +func isInLangList(code string) bool { for _, lang := range languages { if lang.Code == code { return true diff --git a/googletranslate/speech.go b/googletranslate/speech.go index 2366f24..e705003 100644 --- a/googletranslate/speech.go +++ b/googletranslate/speech.go @@ -6,9 +6,7 @@ import ( "log" ) -const ( - speechURL = "https://translate.google.com/translate_tts" -) +const speechURL = "https://translate.google.com/translate_tts" func FetchSoundFile(lang string, text string, audioPath string) (err error) { return fetchSoundFile(speechURL, lang, text, audioPath) diff --git a/googletranslate/translate.go b/googletranslate/translate.go index 07c3ce2..048da42 100644 --- a/googletranslate/translate.go +++ b/googletranslate/translate.go @@ -7,7 +7,7 @@ import ( "strings" ) -const urlAddress = "https://translate.google.com/translate_a/t" +const translateURL = "https://translate.google.com/translate_a/t" type Phrase struct { Translation string `json:"translation"` @@ -18,19 +18,19 @@ func Translate(from string, to string, term string) (phrase Phrase, err error) { argError := func(code string) error { return fmt.Errorf("Unknown language code: %v. Check the list of available codes", code) } - if inLangList(from) == false { + if isInLangList(from) == false { err = argError(from) return } - if inLangList(to) == false { + if isInLangList(to) == false { err = argError(to) return } - return translate(urlAddress, from, to, term) + return translate(translateURL, from, to, term) } -func translate(urlAddress string, from string, to string, term string) (phrase Phrase, err error) { +func translate(translateURL string, from string, to string, term string) (phrase Phrase, err error) { params := map[string]string{ "client": "t", "hl": "en", @@ -44,7 +44,7 @@ func translate(urlAddress string, from string, to string, term string) (phrase P "text": term, } - resp, err := runRquest(urlAddress, params) + resp, err := runRquest(translateURL, params) if err != nil { err = fmt.Errorf("Error fetching translation: [%v]", err) return