Index: /trunk/engines/google.go
===================================================================
--- /trunk/engines/google.go	(revision 39)
+++ /trunk/engines/google.go	(revision 40)
@@ -154,113 +154,114 @@
 	}
 	responseText := string(bodyBytes)
-
-	responseText = regexp.MustCompile(`\n\d+\n(.*)\n\d+\n`).FindStringSubmatch(responseText)[1]
-
-	var raw []interface{}
-	err = json.Unmarshal([]byte(responseText), &raw)
-	if err != nil {
-		fmt.Println("Error:", err)
-		return TranslationResult{}, nil
-	}
+	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(raw) > 0 && raw[0] != nil &&
-		len(raw[0].([]interface{})) > 2 && raw[0].([]interface{})[2] != nil {
-		data := raw[0].([]interface{})[2].(string)
-
-		var json_ []interface{}
-		err = json.Unmarshal([]byte(data), &json_)
-
-		if len(json_) > 3 && json_[3] != nil &&
-			len(json_[3].([]interface{})) > 1 && json_[3].([]interface{})[1] != nil &&
-			len(json_[3].([]interface{})[1].([]interface{})) > 0 && json_[3].([]interface{})[1].([]interface{})[0] != nil {
-			for x := 0; x < len(json_[3].([]interface{})[1].([]interface{})[0].([]interface{})); x++ {
-				if len(json_[3].([]interface{})[1].([]interface{})[0].([]interface{})[x].([]interface{})) > 0 {
-					definitionType := json_[3].([]interface{})[1].([]interface{})[0].([]interface{})[x].([]interface{})[0]
-					if definitionType == nil {
-						definitionType = "unknown"
-					}
-
-					definitions[definitionType.(string)] = []map[string]interface{}{}
-
-					for i := 0; i < len(json_[3].([]interface{})[1].([]interface{})[0].([]interface{})[x].([]interface{})[1].([]interface{})); i++ {
-						definitionBox := json_[3].([]interface{})[1].([]interface{})[0].([]interface{})[x].([]interface{})[1].([]interface{})[i].([]interface{})
-						definitions[definitionType.(string)] = append(definitions[definitionType.(string)], map[string]interface{}{})
-
-						if len(definitionBox) > 4 && definitionBox[4] != nil &&
-							len(definitionBox[4].([]interface{})) > 0 && definitionBox[4].([]interface{})[0] != nil &&
-							len(definitionBox[4].([]interface{})[0].([]interface{})) > 0 && definitionBox[4].([]interface{})[0].([]interface{})[0] != nil {
-							definitions[definitionType.(string)][i]["dictionary"] = definitionBox[4].([]interface{})[0].([]interface{})[0]
-						}
-
-						if len(definitionBox) > 0 && definitionBox[0] != nil {
-							definitions[definitionType.(string)][i]["definition"] = definitionBox[0]
-						}
-
-						if len(definitionBox) > 1 && definitionBox[1] != nil {
-							definitions[definitionType.(string)][i]["use_in_sentence"] = definitionBox[1]
-						}
-
-						if len(definitionBox) > 5 && definitionBox[5] != nil {
-							definitions[definitionType.(string)][i]["synonyms"] = map[string][]string{}
-							synonyms := definitionBox[5].([]interface{})
-							synonymsMap := make(map[string][]string)
-
-							for _, synonymBox := range synonyms {
-								synonymType := ""
-								if len(synonymBox.([]interface{})) > 1 && synonymBox.([]interface{})[1] != nil &&
-									len(synonymBox.([]interface{})[1].([]interface{})) > 0 && synonymBox.([]interface{})[1].([]interface{})[0] != nil {
-									synonymType = synonymBox.([]interface{})[1].([]interface{})[0].([]interface{})[0].(string)
-								}
-
-								if len(synonymBox.([]interface{})) > 0 && synonymBox.([]interface{})[0] != nil {
-									synonymList := synonymBox.([]interface{})[0].([]interface{})
-									synonymsMap[synonymType] = []string{}
-									for _, synonymTypeWord := range synonymList {
-										synonymsMap[synonymType] = append(synonymsMap[synonymType], synonymTypeWord.([]interface{})[0].(string))
+	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
+		}
+
+		if len(raw) > 0 && raw[0] != nil &&
+			len(raw[0].([]interface{})) > 2 && raw[0].([]interface{})[2] != nil {
+			data := raw[0].([]interface{})[2].(string)
+
+			var json_ []interface{}
+			err = json.Unmarshal([]byte(data), &json_)
+
+			if len(json_) > 3 && json_[3] != nil &&
+				len(json_[3].([]interface{})) > 1 && json_[3].([]interface{})[1] != nil &&
+				len(json_[3].([]interface{})[1].([]interface{})) > 0 && json_[3].([]interface{})[1].([]interface{})[0] != nil {
+				for x := 0; x < len(json_[3].([]interface{})[1].([]interface{})[0].([]interface{})); x++ {
+					if len(json_[3].([]interface{})[1].([]interface{})[0].([]interface{})[x].([]interface{})) > 0 {
+						definitionType := json_[3].([]interface{})[1].([]interface{})[0].([]interface{})[x].([]interface{})[0]
+						if definitionType == nil {
+							definitionType = "unknown"
+						}
+
+						definitions[definitionType.(string)] = []map[string]interface{}{}
+
+						for i := 0; i < len(json_[3].([]interface{})[1].([]interface{})[0].([]interface{})[x].([]interface{})[1].([]interface{})); i++ {
+							definitionBox := json_[3].([]interface{})[1].([]interface{})[0].([]interface{})[x].([]interface{})[1].([]interface{})[i].([]interface{})
+							definitions[definitionType.(string)] = append(definitions[definitionType.(string)], map[string]interface{}{})
+
+							if len(definitionBox) > 4 && definitionBox[4] != nil &&
+								len(definitionBox[4].([]interface{})) > 0 && definitionBox[4].([]interface{})[0] != nil &&
+								len(definitionBox[4].([]interface{})[0].([]interface{})) > 0 && definitionBox[4].([]interface{})[0].([]interface{})[0] != nil {
+								definitions[definitionType.(string)][i]["dictionary"] = definitionBox[4].([]interface{})[0].([]interface{})[0]
+							}
+
+							if len(definitionBox) > 0 && definitionBox[0] != nil {
+								definitions[definitionType.(string)][i]["definition"] = definitionBox[0]
+							}
+
+							if len(definitionBox) > 1 && definitionBox[1] != nil {
+								definitions[definitionType.(string)][i]["use_in_sentence"] = definitionBox[1]
+							}
+
+							if len(definitionBox) > 5 && definitionBox[5] != nil {
+								definitions[definitionType.(string)][i]["synonyms"] = map[string][]string{}
+								synonyms := definitionBox[5].([]interface{})
+								synonymsMap := make(map[string][]string)
+
+								for _, synonymBox := range synonyms {
+									synonymType := ""
+									if len(synonymBox.([]interface{})) > 1 && synonymBox.([]interface{})[1] != nil &&
+										len(synonymBox.([]interface{})[1].([]interface{})) > 0 && synonymBox.([]interface{})[1].([]interface{})[0] != nil {
+										synonymType = synonymBox.([]interface{})[1].([]interface{})[0].([]interface{})[0].(string)
+									}
+
+									if len(synonymBox.([]interface{})) > 0 && synonymBox.([]interface{})[0] != nil {
+										synonymList := synonymBox.([]interface{})[0].([]interface{})
+										synonymsMap[synonymType] = []string{}
+										for _, synonymTypeWord := range synonymList {
+											synonymsMap[synonymType] = append(synonymsMap[synonymType], synonymTypeWord.([]interface{})[0].(string))
+										}
 									}
 								}
-							}
-
-							definitions[definitionType.(string)][i]["synonyms"] = synonymsMap
+
+								definitions[definitionType.(string)][i]["synonyms"] = synonymsMap
+							}
 						}
 					}
 				}
 			}
-		}
-
-		if len(json_) > 3 && json_[3] != nil &&
-			len(json_[3].([]interface{})) > 5 && json_[3].([]interface{})[5] != nil &&
-			len(json_[3].([]interface{})[5].([]interface{})) > 0 && json_[3].([]interface{})[5].([]interface{})[0] != nil {
-			translationBox := json_[3].([]interface{})[5].([]interface{})[0].([]interface{})
-			for x := 0; x < len(translationBox); x++ {
-				if len(translationBox[x].([]interface{})) > 0 {
-					translationType := translationBox[x].([]interface{})[0]
-					if translationType == nil {
-						translationType = "unknown"
-					}
-					translations[translationType.(string)] = make(map[string]map[string]interface{})
-
-					if len(translationBox[x].([]interface{})) > 1 && translationBox[x].([]interface{})[1] != nil {
-						translationNamesBox := translationBox[x].([]interface{})[1].([]interface{})
-						for i := 0; i < len(translationNamesBox); i++ {
-							if len(translationNamesBox[i].([]interface{})) > 0 && translationNamesBox[i].([]interface{})[0] != nil {
-								translationName := translationNamesBox[i].([]interface{})[0].(string)
-								translations[translationType.(string)][translationName] = make(map[string]interface{})
-								if len(translationNamesBox[i].([]interface{})) > 3 && translationNamesBox[i].([]interface{})[3] != nil {
-									frequency := fmt.Sprintf("%d", int(translationNamesBox[i].([]interface{})[3].(float64)))
-									if frequency == "3" {
-										frequency = "1"
-									} else if frequency == "1" {
-										frequency = "3"
-									}
-									translations[translationType.(string)][translationName]["frequency"] = frequency + "/3"
-
-									translations[translationType.(string)][translationName]["words"] = []string{}
-									if len(translationNamesBox[i].([]interface{})) > 2 && translationNamesBox[i].([]interface{})[2] != nil {
-										for z := 0; z < len(translationNamesBox[i].([]interface{})[2].([]interface{})); z++ {
-											word := translationNamesBox[i].([]interface{})[2].([]interface{})[z].(string)
-											translations[translationType.(string)][translationName]["words"] = append(translations[translationType.(string)][translationName]["words"].([]string), word)
+
+			if len(json_) > 3 && json_[3] != nil &&
+				len(json_[3].([]interface{})) > 5 && json_[3].([]interface{})[5] != nil &&
+				len(json_[3].([]interface{})[5].([]interface{})) > 0 && json_[3].([]interface{})[5].([]interface{})[0] != nil {
+				translationBox := json_[3].([]interface{})[5].([]interface{})[0].([]interface{})
+				for x := 0; x < len(translationBox); x++ {
+					if len(translationBox[x].([]interface{})) > 0 {
+						translationType := translationBox[x].([]interface{})[0]
+						if translationType == nil {
+							translationType = "unknown"
+						}
+						translations[translationType.(string)] = make(map[string]map[string]interface{})
+
+						if len(translationBox[x].([]interface{})) > 1 && translationBox[x].([]interface{})[1] != nil {
+							translationNamesBox := translationBox[x].([]interface{})[1].([]interface{})
+							for i := 0; i < len(translationNamesBox); i++ {
+								if len(translationNamesBox[i].([]interface{})) > 0 && translationNamesBox[i].([]interface{})[0] != nil {
+									translationName := translationNamesBox[i].([]interface{})[0].(string)
+									translations[translationType.(string)][translationName] = make(map[string]interface{})
+									if len(translationNamesBox[i].([]interface{})) > 3 && translationNamesBox[i].([]interface{})[3] != nil {
+										frequency := fmt.Sprintf("%d", int(translationNamesBox[i].([]interface{})[3].(float64)))
+										if frequency == "3" {
+											frequency = "1"
+										} else if frequency == "1" {
+											frequency = "3"
+										}
+										translations[translationType.(string)][translationName]["frequency"] = frequency + "/3"
+
+										translations[translationType.(string)][translationName]["words"] = []string{}
+										if len(translationNamesBox[i].([]interface{})) > 2 && translationNamesBox[i].([]interface{})[2] != nil {
+											for z := 0; z < len(translationNamesBox[i].([]interface{})[2].([]interface{})); z++ {
+												word := translationNamesBox[i].([]interface{})[2].([]interface{})[z].(string)
+												translations[translationType.(string)][translationName]["words"] = append(translations[translationType.(string)][translationName]["words"].([]string), word)
+											}
 										}
 									}
@@ -271,8 +272,9 @@
 				}
 			}
-		}
-
-		if len(json_) > 0 && json_[0] != nil && len(json_[0].([]interface{})) > 2 && json_[0].([]interface{})[2] != nil {
-			from = json_[0].([]interface{})[2].(string)
+
+			if len(json_) > 0 && json_[0] != nil && len(json_[0].([]interface{})) > 2 && json_[0].([]interface{})[2] != nil {
+				from = json_[0].([]interface{})[2].(string)
+			}
+
 		}
 	}
