Fixed bug
git-svn-id: file:///srv/svn/repo/mai/trunk@40 e410bdd4-646f-c54f-a7ce-fffcc4f439ae
This commit is contained in:
parent
c823d2d810
commit
4b15e86631
@ -153,17 +153,17 @@ func (_ *GoogleTranslate) Translate(text string, from, to string) (TranslationRe
|
||||
return TranslationResult{}, nil
|
||||
}
|
||||
responseText := string(bodyBytes)
|
||||
|
||||
responseText = regexp.MustCompile(`\n\d+\n(.*)\n\d+\n`).FindStringSubmatch(responseText)[1]
|
||||
|
||||
responseTextList := regexp.MustCompile(`\n\d+\n(.*)\n\d+\n`).FindStringSubmatch(responseText)
|
||||
definitions := make(map[string][]map[string]interface{})
|
||||
translations := make(map[string]map[string]map[string]interface{})
|
||||
if len(responseTextList) > 0 {
|
||||
responseText = responseTextList[1]
|
||||
var raw []interface{}
|
||||
err = json.Unmarshal([]byte(responseText), &raw)
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
return TranslationResult{}, nil
|
||||
}
|
||||
definitions := make(map[string][]map[string]interface{})
|
||||
translations := make(map[string]map[string]map[string]interface{})
|
||||
|
||||
if len(raw) > 0 && raw[0] != nil &&
|
||||
len(raw[0].([]interface{})) > 2 && raw[0].([]interface{})[2] != nil {
|
||||
@ -275,6 +275,8 @@ func (_ *GoogleTranslate) Translate(text string, from, to string) (TranslationRe
|
||||
if len(json_) > 0 && json_[0] != nil && len(json_[0].([]interface{})) > 2 && json_[0].([]interface{})[2] != nil {
|
||||
from = json_[0].([]interface{})[2].(string)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if from == "auto" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user