Skip to content

Commit

Permalink
Be consistent with var naming
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrovv committed Aug 3, 2014
1 parent b8e9c08 commit 61b574c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion googletranslate/languages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions googletranslate/speech.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions googletranslate/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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",
Expand All @@ -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
Expand Down

0 comments on commit 61b574c

Please sign in to comment.